From 7b126508de126764954ea0953a88a0d2d06213b0 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 00000000..e9413120 --- /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 00000000..9b429614 --- /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 00000000..b9731f09 --- /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 00000000..c82dd91e --- /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 00000000..84051ceb --- /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 00000000..4d442db9 --- /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 00000000..b647a292 --- /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 00000000..2adaa1f4 --- /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 00000000..6d9e1271 --- /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 00000000..94cc012e --- /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 00000000..6af3aa5e --- /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 00000000..e9e197fa --- /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 00000000..e5aa5567 --- /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 00000000..72f20b3f --- /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 00000000..555283a6 --- /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 f458fa1cb02d058228603b46245ff7404b527f8e Mon Sep 17 00:00:00 2001 From: PauBForgeFlow Date: Tue, 24 Oct 2023 15:54:01 +0200 Subject: [PATCH 2/5] [IMP] rma_refund_reason: pre-commit stuff --- setup/rma_refund_reason/odoo/addons/rma_refund_reason | 1 + setup/rma_refund_reason/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/rma_refund_reason/odoo/addons/rma_refund_reason create mode 100644 setup/rma_refund_reason/setup.py diff --git a/setup/rma_refund_reason/odoo/addons/rma_refund_reason b/setup/rma_refund_reason/odoo/addons/rma_refund_reason new file mode 120000 index 00000000..12b9e379 --- /dev/null +++ b/setup/rma_refund_reason/odoo/addons/rma_refund_reason @@ -0,0 +1 @@ +../../../../rma_refund_reason \ No newline at end of file diff --git a/setup/rma_refund_reason/setup.py b/setup/rma_refund_reason/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/rma_refund_reason/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From ac91fd8d9ef63500292a0f19e1bf5299336d3fee Mon Sep 17 00:00:00 2001 From: PauBForgeFlow Date: Tue, 24 Oct 2023 16:57:07 +0200 Subject: [PATCH 3/5] [MIG] rma_refund_reason: Migration to 16.0 --- rma_refund_reason/__manifest__.py | 4 ++-- test-requirements.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 test-requirements.txt diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py index b9731f09..fe2f1118 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"], diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..5e7a59b1 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-account_invoice_refund_reason@git+https://github.com/ForgeFlow/account-invoicing.git@16.0-mig-account_invoice_refund_reason#subdirectory=setup/account_invoice_refund_reason From aa6c5fc2af153b99b3d5f9b590cf76c41606e2bc Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Tue, 19 Sep 2023 07:31:21 -0500 Subject: [PATCH 4/5] [14.0][FIX] Added a better ux to select or write reason of refund --- rma_account/wizards/rma_refund.py | 16 +++++++++++--- rma_refund_reason/__manifest__.py | 1 + rma_refund_reason/wizard/rma_refund.py | 23 ++++++++++++++++++-- rma_refund_reason/wizard/rma_refund_view.xml | 22 +++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 rma_refund_reason/wizard/rma_refund_view.xml diff --git a/rma_account/wizards/rma_refund.py b/rma_account/wizards/rma_refund.py index e2421c03..a979f327 100644 --- a/rma_account/wizards/rma_refund.py +++ b/rma_account/wizards/rma_refund.py @@ -146,10 +146,20 @@ class RmaRefund(models.TransientModel): journal = self.env["account.journal"].search( [("type", "=", "purchase")], limit=1 ) + rma_number_ref = rma_line.rma_id.name or rma_line.name + reason = wizard.description + if reason == rma_number_ref: + reason = False + ref = _("Refund created by %(rnr)s, %(r)s") % { + "rnr": rma_number_ref, + "r": reason, + } + if not reason: + ref = _("Refund created by %s") % rma_number_ref values = { - "payment_reference": rma_line.rma_id.name or rma_line.name, - "invoice_origin": rma_line.rma_id.name or rma_line.name, - "ref": False, + "payment_reference": rma_number_ref, + "invoice_origin": rma_number_ref, + "ref": ref, "move_type": "in_refund" if rma_line.type == "supplier" else "out_refund", "journal_id": journal.id, "fiscal_position_id": rma_line.partner_id.property_account_position_id.id, diff --git a/rma_refund_reason/__manifest__.py b/rma_refund_reason/__manifest__.py index fe2f1118..77540dd5 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 555283a6..11ecba04 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 00000000..b9ea27c8 --- /dev/null +++ b/rma_refund_reason/wizard/rma_refund_view.xml @@ -0,0 +1,22 @@ + + + + + + rma.refund.form.view + rma.refund + 99 + + + + + + + + + + From e726b5260004f5855010aa776b65fae5716b1565 Mon Sep 17 00:00:00 2001 From: JasminSForgeFlow Date: Wed, 8 May 2024 14:55:58 +0530 Subject: [PATCH 5/5] [IMP] remove test-requirements --- test-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 5e7a59b1..e69de29b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +0,0 @@ -odoo-addon-account_invoice_refund_reason@git+https://github.com/ForgeFlow/account-invoicing.git@16.0-mig-account_invoice_refund_reason#subdirectory=setup/account_invoice_refund_reason