-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][FIX] Added a better ux to select or write reason of refund
- Loading branch information
1 parent
fb9af9b
commit b2b8c0a
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<!-- Inherit Form View to Modify it --> | ||
<record id="view_rma_refund" model="ir.ui.view"> | ||
<field name="name">rma.refund.form.view</field> | ||
<field name="model">rma.refund</field> | ||
<field name="priority">99</field> | ||
<field name="inherit_id" ref="rma_account.view_rma_refund" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='description']" position="replace"> | ||
<field name="description" invisible="1" /> | ||
<field | ||
name="refund_reason_id" | ||
options="{'no_create': True}" | ||
required="1" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |