Skip to content

Commit

Permalink
Merge pull request #465 from ForgeFlow/16.0-mig-rma_refund_reason
Browse files Browse the repository at this point in the history
[16.0][MIG] rma_refund_reason: Migration to 16.0
  • Loading branch information
JordiBForgeFlow authored Jun 21, 2024
2 parents b944f47 + e726b52 commit d53b227
Show file tree
Hide file tree
Showing 20 changed files with 657 additions and 3 deletions.
16 changes: 13 additions & 3 deletions rma_account/wizards/rma_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,20 @@ def _prepare_refund(self, wizard, rma_line):
],
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,
Expand Down
62 changes: 62 additions & 0 deletions rma_refund_reason/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/ForgeFlow/stock-rma/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 <https://github.com/ForgeFlow/stock-rma/issues/new?body=module:%20rma_refund_reason%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* ForgeFlow S.L.

Contributors
~~~~~~~~~~~~

* Christopher Ormaza <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `ForgeFlow/stock-rma <https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_refund_reason>`_ project on GitHub.

You are welcome to contribute.
2 changes: 2 additions & 0 deletions rma_refund_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
20 changes: 20 additions & 0 deletions rma_refund_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 2 additions & 0 deletions rma_refund_reason/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import rma_operation
from . import rma_order_line
14 changes: 14 additions & 0 deletions rma_refund_reason/models/rma_operation.py
Original file line number Diff line number Diff line change
@@ -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",
)
21 changes: 21 additions & 0 deletions rma_refund_reason/models/rma_order_line.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rma_refund_reason/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Christopher Ormaza <[email protected]>
3 changes: 3 additions & 0 deletions rma_refund_reason/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add refund reason on rma refund creation process

The default return reason can be configured in the RMA operations
Loading

0 comments on commit d53b227

Please sign in to comment.