From d8815d5ba6c9eef34bb20497071faa428d7b9d2c Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Thu, 15 Jun 2023 16:05:43 -0500 Subject: [PATCH 1/5] [14.0][ADD] rma_refund_reason --- rma_refund_reason/README.rst | 62 +++ rma_refund_reason/__init__.py | 2 + rma_refund_reason/__manifest__.py | 19 + rma_refund_reason/models/__init__.py | 2 + rma_refund_reason/models/rma_operation.py | 14 + rma_refund_reason/models/rma_order_line.py | 21 + rma_refund_reason/readme/CONTRIBUTORS.rst | 1 + rma_refund_reason/readme/DESCRIPTION.rst | 3 + .../static/description/index.html | 417 ++++++++++++++++++ rma_refund_reason/tests/__init__.py | 1 + .../tests/test_rma_refund_reason.py | 2 + .../views/rma_operation_view.xml | 15 + .../views/rma_order_line_view.xml | 15 + rma_refund_reason/wizard/__init__.py | 1 + rma_refund_reason/wizard/rma_refund.py | 20 + 15 files changed, 595 insertions(+) create mode 100644 rma_refund_reason/README.rst create mode 100644 rma_refund_reason/__init__.py create mode 100644 rma_refund_reason/__manifest__.py create mode 100644 rma_refund_reason/models/__init__.py create mode 100644 rma_refund_reason/models/rma_operation.py create mode 100644 rma_refund_reason/models/rma_order_line.py create mode 100644 rma_refund_reason/readme/CONTRIBUTORS.rst create mode 100644 rma_refund_reason/readme/DESCRIPTION.rst create mode 100644 rma_refund_reason/static/description/index.html create mode 100644 rma_refund_reason/tests/__init__.py create mode 100644 rma_refund_reason/tests/test_rma_refund_reason.py create mode 100644 rma_refund_reason/views/rma_operation_view.xml create mode 100644 rma_refund_reason/views/rma_order_line_view.xml create mode 100644 rma_refund_reason/wizard/__init__.py create mode 100644 rma_refund_reason/wizard/rma_refund.py diff --git a/rma_refund_reason/README.rst b/rma_refund_reason/README.rst new file mode 100644 index 000000000..e94131200 --- /dev/null +++ b/rma_refund_reason/README.rst @@ -0,0 +1,62 @@ +============================= +RMA Refund Reason Integration +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2e403ef31b1be93acf0bed913183ea60c20dc9f6279eee6ae5fab018049bfb44 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github + :target: https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_refund_reason + :alt: ForgeFlow/stock-rma + +|badge1| |badge2| |badge3| + +Add refund reason on rma refund creation process + +The default return reason can be configured in the RMA operations + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* Christopher Ormaza + +Maintainers +~~~~~~~~~~~ + +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. + +You are welcome to contribute. diff --git a/rma_refund_reason/__init__.py b/rma_refund_reason/__init__.py new file mode 100644 index 000000000..9b4296142 --- /dev/null +++ b/rma_refund_reason/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py new file mode 100644 index 000000000..b9731f09e --- /dev/null +++ b/rma_refund_reason/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "RMA Refund Reason Integration", + "version": "14.0.1.0.0", + "summary": "RMA Refund Reason Integration", + "category": "RMA", + "author": "ForgeFlow S.L.", + "website": "https://github.com/ForgeFlow/stock-rma", + "license": "AGPL-3", + "depends": ["rma_account", "account_invoice_refund_reason"], + "data": [ + "views/rma_operation_view.xml", + "views/rma_order_line_view.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/rma_refund_reason/models/__init__.py b/rma_refund_reason/models/__init__.py new file mode 100644 index 000000000..c82dd91e6 --- /dev/null +++ b/rma_refund_reason/models/__init__.py @@ -0,0 +1,2 @@ +from . import rma_operation +from . import rma_order_line diff --git a/rma_refund_reason/models/rma_operation.py b/rma_refund_reason/models/rma_operation.py new file mode 100644 index 000000000..84051ceb6 --- /dev/null +++ b/rma_refund_reason/models/rma_operation.py @@ -0,0 +1,14 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class RmaOperation(models.Model): + + _inherit = "rma.operation" + + refund_reason_id = fields.Many2one( + comodel_name="account.move.refund.reason", + string="Refund reason", + ) diff --git a/rma_refund_reason/models/rma_order_line.py b/rma_refund_reason/models/rma_order_line.py new file mode 100644 index 000000000..4d442db9e --- /dev/null +++ b/rma_refund_reason/models/rma_order_line.py @@ -0,0 +1,21 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class RmaOrderLine(models.Model): + + _inherit = "rma.order.line" + + refund_reason_id = fields.Many2one( + comodel_name="account.move.refund.reason", + string="Refund reason", + ) + + @api.onchange("operation_id") + def _onchange_operation_id(self): + result = super(RmaOrderLine, self)._onchange_operation_id() + if self.operation_id: + self.refund_reason_id = self.operation_id.refund_reason_id.id + return result diff --git a/rma_refund_reason/readme/CONTRIBUTORS.rst b/rma_refund_reason/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b647a292e --- /dev/null +++ b/rma_refund_reason/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Christopher Ormaza diff --git a/rma_refund_reason/readme/DESCRIPTION.rst b/rma_refund_reason/readme/DESCRIPTION.rst new file mode 100644 index 000000000..2adaa1f46 --- /dev/null +++ b/rma_refund_reason/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Add refund reason on rma refund creation process + +The default return reason can be configured in the RMA operations diff --git a/rma_refund_reason/static/description/index.html b/rma_refund_reason/static/description/index.html new file mode 100644 index 000000000..6d9e1271b --- /dev/null +++ b/rma_refund_reason/static/description/index.html @@ -0,0 +1,417 @@ + + + + + + +RMA Refund Reason Integration + + + +
+

RMA Refund Reason Integration

+ + +

Beta License: AGPL-3 ForgeFlow/stock-rma

+

Add refund reason on rma refund creation process

+

The default return reason can be configured in the RMA operations

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the ForgeFlow/stock-rma project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/rma_refund_reason/tests/__init__.py b/rma_refund_reason/tests/__init__.py new file mode 100644 index 000000000..94cc012e7 --- /dev/null +++ b/rma_refund_reason/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_refund_reason diff --git a/rma_refund_reason/tests/test_rma_refund_reason.py b/rma_refund_reason/tests/test_rma_refund_reason.py new file mode 100644 index 000000000..6af3aa5e0 --- /dev/null +++ b/rma_refund_reason/tests/test_rma_refund_reason.py @@ -0,0 +1,2 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/rma_refund_reason/views/rma_operation_view.xml b/rma_refund_reason/views/rma_operation_view.xml new file mode 100644 index 000000000..e9e197fa3 --- /dev/null +++ b/rma_refund_reason/views/rma_operation_view.xml @@ -0,0 +1,15 @@ + + + + + rma.operation.form.view + rma.operation + + + + + + + + + diff --git a/rma_refund_reason/views/rma_order_line_view.xml b/rma_refund_reason/views/rma_order_line_view.xml new file mode 100644 index 000000000..e5aa5567e --- /dev/null +++ b/rma_refund_reason/views/rma_order_line_view.xml @@ -0,0 +1,15 @@ + + + + + rma.order.line.form.view + rma.order.line + + + + + + + + + diff --git a/rma_refund_reason/wizard/__init__.py b/rma_refund_reason/wizard/__init__.py new file mode 100644 index 000000000..72f20b3f9 --- /dev/null +++ b/rma_refund_reason/wizard/__init__.py @@ -0,0 +1 @@ +from . import rma_refund diff --git a/rma_refund_reason/wizard/rma_refund.py b/rma_refund_reason/wizard/rma_refund.py new file mode 100644 index 000000000..555283a60 --- /dev/null +++ b/rma_refund_reason/wizard/rma_refund.py @@ -0,0 +1,20 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class RmaRefund(models.TransientModel): + + _inherit = "rma.refund" + + @api.model + def _prepare_refund(self, wizard, rma_line): + values = super(RmaRefund, self)._prepare_refund(wizard, rma_line) + if rma_line.refund_reason_id: + values.update( + { + "reason_id": rma_line.refund_reason_id.id, + } + ) + return values From b46ca8edbe1ecff99eebbc57981841c5768643c6 Mon Sep 17 00:00:00 2001 From: PauBForgeFlow Date: Tue, 24 Oct 2023 16:57:07 +0200 Subject: [PATCH 2/5] [MIG] rma_refund_reason: Migration to 16.0 --- rma_refund_reason/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py index b9731f09e..fe2f11185 100644 --- a/rma_refund_reason/__manifest__.py +++ b/rma_refund_reason/__manifest__.py @@ -3,10 +3,10 @@ { "name": "RMA Refund Reason Integration", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "summary": "RMA Refund Reason Integration", "category": "RMA", - "author": "ForgeFlow S.L.", + "author": "ForgeFlow", "website": "https://github.com/ForgeFlow/stock-rma", "license": "AGPL-3", "depends": ["rma_account", "account_invoice_refund_reason"], From ff032bb0fd35a2f616153c74f8fbc1de36b97c8c Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Tue, 19 Sep 2023 07:31:21 -0500 Subject: [PATCH 3/5] [14.0][FIX] Added a better ux to select or write reason of refund --- rma_refund_reason/__manifest__.py | 1 + rma_refund_reason/wizard/rma_refund.py | 23 ++++++++++++++++++-- rma_refund_reason/wizard/rma_refund_view.xml | 22 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 rma_refund_reason/wizard/rma_refund_view.xml diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py index fe2f11185..77540dd52 100644 --- a/rma_refund_reason/__manifest__.py +++ b/rma_refund_reason/__manifest__.py @@ -13,6 +13,7 @@ "data": [ "views/rma_operation_view.xml", "views/rma_order_line_view.xml", + "wizard/rma_refund_view.xml", ], "installable": True, "auto_install": True, diff --git a/rma_refund_reason/wizard/rma_refund.py b/rma_refund_reason/wizard/rma_refund.py index 555283a60..11ecba046 100644 --- a/rma_refund_reason/wizard/rma_refund.py +++ b/rma_refund_reason/wizard/rma_refund.py @@ -1,20 +1,39 @@ # Copyright (C) 2023 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models +from odoo import api, fields, models class RmaRefund(models.TransientModel): _inherit = "rma.refund" + @api.model + def _get_refund_reason(self): + active_ids = self.env.context.get("active_ids", False) + return ( + active_ids + and self.env["rma.order.line"].browse(active_ids[0]).refund_reason_id.id + or False + ) + + refund_reason_id = fields.Many2one( + comodel_name="account.move.refund.reason", + string="Refund Reason", + default=lambda self: self._get_refund_reason(), + ) + + @api.onchange("refund_reason_id") + def _onchange_refund_reason_id(self): + self.description = self.refund_reason_id.name + @api.model def _prepare_refund(self, wizard, rma_line): values = super(RmaRefund, self)._prepare_refund(wizard, rma_line) if rma_line.refund_reason_id: values.update( { - "reason_id": rma_line.refund_reason_id.id, + "reason_id": wizard.refund_reason_id.id, } ) return values diff --git a/rma_refund_reason/wizard/rma_refund_view.xml b/rma_refund_reason/wizard/rma_refund_view.xml new file mode 100644 index 000000000..b9ea27c8a --- /dev/null +++ b/rma_refund_reason/wizard/rma_refund_view.xml @@ -0,0 +1,22 @@ + + + + + + rma.refund.form.view + rma.refund + 99 + + + + + + + + + + From eba39f679080129581b055c8d7bb4dd56dbecbe8 Mon Sep 17 00:00:00 2001 From: JasminSForgeFlow Date: Thu, 8 May 2025 10:17:28 +0530 Subject: [PATCH 4/5] [IMP] rma_refund_reason: black, isort, prettier --- rma_refund_reason/README.rst | 16 ++++---- rma_refund_reason/__manifest__.py | 2 +- rma_refund_reason/models/rma_operation.py | 1 - rma_refund_reason/models/rma_order_line.py | 3 +- rma_refund_reason/pyproject.toml | 3 ++ rma_refund_reason/readme/CONTRIBUTORS.md | 1 + rma_refund_reason/readme/CONTRIBUTORS.rst | 1 - .../{DESCRIPTION.rst => DESCRIPTION.md} | 0 .../static/description/index.html | 40 +++++++++---------- .../views/rma_operation_view.xml | 2 - .../views/rma_order_line_view.xml | 2 - rma_refund_reason/wizard/rma_refund.py | 3 +- rma_refund_reason/wizard/rma_refund_view.xml | 2 - 13 files changed, 35 insertions(+), 41 deletions(-) create mode 100644 rma_refund_reason/pyproject.toml create mode 100644 rma_refund_reason/readme/CONTRIBUTORS.md delete mode 100644 rma_refund_reason/readme/CONTRIBUTORS.rst rename rma_refund_reason/readme/{DESCRIPTION.rst => DESCRIPTION.md} (100%) diff --git a/rma_refund_reason/README.rst b/rma_refund_reason/README.rst index e94131200..b7b2f043e 100644 --- a/rma_refund_reason/README.rst +++ b/rma_refund_reason/README.rst @@ -17,7 +17,7 @@ RMA Refund Reason Integration :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github - :target: https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_refund_reason + :target: https://github.com/ForgeFlow/stock-rma/tree/18.0/rma_refund_reason :alt: ForgeFlow/stock-rma |badge1| |badge2| |badge3| @@ -37,7 +37,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -45,18 +45,18 @@ Credits ======= Authors -~~~~~~~ +------- -* ForgeFlow S.L. +* ForgeFlow Contributors -~~~~~~~~~~~~ +------------ -* Christopher Ormaza +- Christopher Ormaza Maintainers -~~~~~~~~~~~ +----------- -This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. You are welcome to contribute. diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py index 77540dd52..49388a2bc 100644 --- a/rma_refund_reason/__manifest__.py +++ b/rma_refund_reason/__manifest__.py @@ -7,7 +7,7 @@ "summary": "RMA Refund Reason Integration", "category": "RMA", "author": "ForgeFlow", - "website": "https://github.com/ForgeFlow/stock-rma", + "website": "https://github.com/ForgeFlow", "license": "AGPL-3", "depends": ["rma_account", "account_invoice_refund_reason"], "data": [ diff --git a/rma_refund_reason/models/rma_operation.py b/rma_refund_reason/models/rma_operation.py index 84051ceb6..d8e4d8f0c 100644 --- a/rma_refund_reason/models/rma_operation.py +++ b/rma_refund_reason/models/rma_operation.py @@ -5,7 +5,6 @@ class RmaOperation(models.Model): - _inherit = "rma.operation" refund_reason_id = fields.Many2one( diff --git a/rma_refund_reason/models/rma_order_line.py b/rma_refund_reason/models/rma_order_line.py index 4d442db9e..8afa7bd82 100644 --- a/rma_refund_reason/models/rma_order_line.py +++ b/rma_refund_reason/models/rma_order_line.py @@ -5,7 +5,6 @@ class RmaOrderLine(models.Model): - _inherit = "rma.order.line" refund_reason_id = fields.Many2one( @@ -15,7 +14,7 @@ class RmaOrderLine(models.Model): @api.onchange("operation_id") def _onchange_operation_id(self): - result = super(RmaOrderLine, self)._onchange_operation_id() + result = super()._onchange_operation_id() if self.operation_id: self.refund_reason_id = self.operation_id.refund_reason_id.id return result diff --git a/rma_refund_reason/pyproject.toml b/rma_refund_reason/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/rma_refund_reason/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/rma_refund_reason/readme/CONTRIBUTORS.md b/rma_refund_reason/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..9b6d3655b --- /dev/null +++ b/rma_refund_reason/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Christopher Ormaza \<\> diff --git a/rma_refund_reason/readme/CONTRIBUTORS.rst b/rma_refund_reason/readme/CONTRIBUTORS.rst deleted file mode 100644 index b647a292e..000000000 --- a/rma_refund_reason/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Christopher Ormaza diff --git a/rma_refund_reason/readme/DESCRIPTION.rst b/rma_refund_reason/readme/DESCRIPTION.md similarity index 100% rename from rma_refund_reason/readme/DESCRIPTION.rst rename to rma_refund_reason/readme/DESCRIPTION.md diff --git a/rma_refund_reason/static/description/index.html b/rma_refund_reason/static/description/index.html index 6d9e1271b..6070cc6a7 100644 --- a/rma_refund_reason/static/description/index.html +++ b/rma_refund_reason/static/description/index.html @@ -1,20 +1,20 @@ - - + RMA Refund Reason Integration