Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion rma_sale_lot/wizards/sale_order_rma_wizard.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Comment on lines +31 to +35

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with adding a domain, because before this commit, any lot could be selected, even lots that belong to other products, which is an error.
But I also think this domain can be too restrictive; I’m not sure, so I’ll wait for more opinions in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of the RMA creation wizard from a sales order, in my opinion, you should only be able to select the lots that have been used and not others, don't you think?


@api.depends("product_id.tracking")
def _compute_lots_visible(self):
for rec in self:
Expand Down
Loading