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: 12 additions & 3 deletions stock_picking_return_lot/wizards/stock_return_picking_line.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 @@ -17,12 +18,20 @@ class StockReturnPickingLine(models.TransientModel):
)
]

lot_id_domain = fields.Binary(compute="_compute_lot_id_domain")
lot_id = fields.Many2one(
"stock.lot",
string="Lot/Serial Number",
domain="[('product_id', '=', product_id)]",
"stock.lot", string="Lot/Serial Number", domain="lot_id_domain"
)

@api.depends("move_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 +29 to +33
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is it so restrictive?
The same as my comment here: OCA/rma#554 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Similar to what was discussed in the other PR, IMO you should only be able to select lots that have been used; what would be the point of creating a return for a lot that hasn't been used?


def _prepare_move_default_values(self, picking):
# Set the wizard line lot as the move's restricted lot
vals = super()._prepare_move_default_values(picking)
Expand Down
Loading