diff --git a/rma_sale/models/sale.py b/rma_sale/models/sale.py index 97b6209e9..f80839ccf 100644 --- a/rma_sale/models/sale.py +++ b/rma_sale/models/sale.py @@ -34,6 +34,7 @@ def _prepare_rma_wizard_line_vals(self, data): "sale_line_id": data["sale_line_id"].id, "uom_id": data["uom"].id, "picking_id": data["picking"] and data["picking"].id, + "move_id": data.get("move") and data.get("move").id or False, } def action_create_rma(self): @@ -162,6 +163,7 @@ def _get_chained_moves(_moves, done_moves=None): "uom": move.product_uom, "picking": move.picking_id, "sale_line_id": self, + "move": move, } ) else: diff --git a/rma_sale/wizard/sale_order_rma_wizard.py b/rma_sale/wizard/sale_order_rma_wizard.py index 60146c84f..192bc80cb 100644 --- a/rma_sale/wizard/sale_order_rma_wizard.py +++ b/rma_sale/wizard/sale_order_rma_wizard.py @@ -1,5 +1,6 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # Copyright 2022 Tecnativa - Víctor Martínez +# Copyright 2024 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import SUPERUSER_ID, _, api, fields, models @@ -145,7 +146,7 @@ class SaleOrderLineRmaWizard(models.TransientModel): string="Delivery order", domain="[('id', 'in', allowed_picking_ids)]", ) - move_id = fields.Many2one(comodel_name="stock.move", compute="_compute_move_id") + move_id = fields.Many2one(comodel_name="stock.move") operation_id = fields.Many2one( comodel_name="rma.operation", string="Requested operation", @@ -169,21 +170,6 @@ def onchange_product_id(self): self.picking_id = False self.uom_id = self.product_id.uom_id - @api.depends("picking_id") - def _compute_move_id(self): - for record in self: - move_id = False - if record.picking_id: - move_id = record.picking_id.move_ids.filtered( - lambda r: ( - r.sale_line_id == record.sale_line_id - and r.sale_line_id.product_id == record.product_id - and r.sale_line_id.order_id == record.order_id - and r.state == "done" - ) - ) - record.move_id = move_id - @api.depends("order_id") def _compute_allowed_product_ids(self): for record in self: diff --git a/rma_sale/wizard/sale_order_rma_wizard_views.xml b/rma_sale/wizard/sale_order_rma_wizard_views.xml index 24e0f0cb4..fb2f6a87c 100644 --- a/rma_sale/wizard/sale_order_rma_wizard_views.xml +++ b/rma_sale/wizard/sale_order_rma_wizard_views.xml @@ -26,6 +26,7 @@ options="{'no_create': True}" /> +