Skip to content

Commit

Permalink
[IMP] rma_reason: add rma reason to stock return wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Aug 15, 2024
1 parent b0f2031 commit 1696b0a
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions rma_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizards
1 change: 1 addition & 0 deletions rma_reason/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"views/rma_reason.xml",
"views/res_config_settings.xml",
"views/rma_portal_templates.xml",
"wizards/stock_return_picking.xml",
],
"demo": [
"demo/rma_reason.xml",
Expand Down
2 changes: 2 additions & 0 deletions rma_reason/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_return_picking
from . import stock_return_picking_line
11 changes: 11 additions & 0 deletions rma_reason/wizards/stock_return_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockReturnPicking(models.TransientModel):

_inherit = "stock.return.picking"

rma_reason_id = fields.Many2one(comodel_name="rma.reason", readonly=False)
31 changes: 31 additions & 0 deletions rma_reason/wizards/stock_return_picking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="stock_return_picking_form_view">
<field name="model">stock.return.picking</field>
<field name="inherit_id" ref="stock.view_stock_return_picking_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='product_return_moves']//tree" position="inside">
<field
name="rma_reason_id"
attrs="{'column_invisible': [('parent.create_rma', '=', False)], 'required': [('is_rma_reason_required', '=', True)]}"
/>
<field name="is_rma_reason_required" invisible="1" />
</xpath>
<xpath
expr="//group[@name='group_rma']//field[@name='rma_operation_id']"
position="before"
>
<field
name="rma_reason_id"
attrs="{'invisible': [('create_rma', '=', False)]}"
/>
</xpath>
</field>
</record>



</odoo>
31 changes: 31 additions & 0 deletions rma_reason/wizards/stock_return_picking_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockReturnPickingLine(models.TransientModel):

_inherit = "stock.return.picking.line"

rma_reason_id = fields.Many2one(
comodel_name="rma.reason",
compute="_compute_rma_reason_id",
store=True,
readonly=False,
)
is_rma_reason_required = fields.Boolean(
related="wizard_id.company_id.is_rma_reason_required"
)

@api.depends("wizard_id.rma_reason_id")
def _compute_rma_reason_id(self):
for rec in self:
if rec.wizard_id.rma_reason_id:
rec.rma_reason_id = rec.wizard_id.rma_reason_id

def _prepare_rma_vals(self):
self.ensure_one()
vals = super()._prepare_rma_vals()
vals["reason_id"] = self.rma_reason_id.id
return vals
2 changes: 1 addition & 1 deletion rma_sale_reason/views/rma_portal_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name="My RMA"
inherit_id="rma_sale.sale_rma_request_form"
>
<xpath expr="//t[@t-set='operations']" position="after">
<xpath expr="//t[@t-set='operations']" position="before">

<t t-set="reasons" t-value="sale_order.env['rma.reason'].search([])" />

Expand Down
2 changes: 1 addition & 1 deletion rma_sale_reason/wizards/sale_order_rma_wizard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</xpath>
<xpath
expr="//field[@name='line_ids']//field[@name='operation_id']"
position="after"
position="before"
>
<field name="is_rma_reason_required" invisible="True" />
<field
Expand Down

0 comments on commit 1696b0a

Please sign in to comment.