diff --git a/rma_account/wizards/rma_refund.py b/rma_account/wizards/rma_refund.py index c641223e..c03d3895 100644 --- a/rma_account/wizards/rma_refund.py +++ b/rma_account/wizards/rma_refund.py @@ -151,10 +151,20 @@ class RmaRefund(models.TransientModel): ], 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/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..77540dd5 --- /dev/null +++ b/rma_refund_reason/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright (C) 2023 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "RMA Refund Reason Integration", + "version": "16.0.1.0.0", + "summary": "RMA Refund Reason Integration", + "category": "RMA", + "author": "ForgeFlow", + "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", + "wizard/rma_refund_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..11ecba04 --- /dev/null +++ b/rma_refund_reason/wizard/rma_refund.py @@ -0,0 +1,39 @@ +# 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 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": 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 + + + + + + + + + + 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, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..e69de29b