From f17649ed7ed2e998d14ee508fec171e541235608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 18 Mar 2026 14:18:56 +0100 Subject: [PATCH] [FIX] rma_sale_lot: Add domain to the lot_id field so that only the appropriate lots can be selected TT61559 --- rma_sale_lot/wizards/sale_order_rma_wizard.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rma_sale_lot/wizards/sale_order_rma_wizard.py b/rma_sale_lot/wizards/sale_order_rma_wizard.py index 6db52ccb4..e3012507d 100644 --- a/rma_sale_lot/wizards/sale_order_rma_wizard.py +++ b/rma_sale_lot/wizards/sale_order_rma_wizard.py @@ -1,4 +1,5 @@ # Copyright 2024 ACSONE SA/NV +# Copyright 2026 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, fields, models @@ -18,9 +19,21 @@ def _compute_lots_visible(self): class SaleOrderLineRmaWizard(models.TransientModel): _inherit = "sale.order.line.rma.wizard" - lot_id = fields.Many2one(comodel_name="stock.lot", string="Lot/Serial Number") + lot_id_domain = fields.Binary(compute="_compute_lot_id_domain") + lot_id = fields.Many2one( + comodel_name="stock.lot", string="Lot/Serial Number", domain="lot_id_domain" + ) lots_visible = fields.Boolean(compute="_compute_lots_visible") + @api.depends("move_id", "product_id") + def _compute_lot_id_domain(self): + for rec in self: + smls = rec.move_id.move_line_ids.filtered( + lambda x: x.state == "done" and x.lot_id + ) + domain = [("id", "in", smls.lot_id.ids)] + rec.lot_id_domain = domain + @api.depends("product_id.tracking") def _compute_lots_visible(self): for rec in self: