[FIX] stock_quant_manual_assign: Correct handling of immediate transfers

This commit fixes the following issues:

- The previous code does not handle the immediate transfer scenario when
  auto_fill_qty_done is selected in the operation type. This raises a missing-record
  error, trying to update qty_done on non-existing move line records.
- move._do_unreserve() keeps existing stock.move.line records if there is some
  qty_done set, which is not a desirable outcome. All the linked move line records
  should be unlinked before selected quants are assigned.
This commit is contained in:
Yoshi Tashiro
2024-05-18 08:46:04 +00:00
committed by Aungkokolin1997
parent d5ebefb538
commit c7dc47b9c2
5 changed files with 74 additions and 75 deletions

View File

@@ -60,13 +60,16 @@ class AssignManualQuants(models.TransientModel):
def assign_quants(self):
move = self.move_id
move._do_unreserve()
self.move_id.move_line_ids.unlink()
for line in self.quants_lines:
line._assign_quant_line()
if move.picking_type_id.auto_fill_qty_done:
# Auto-fill all lines as done
for ml in move.move_line_ids:
ml.qty_done = ml.reserved_uom_qty
if move.from_immediate_transfer:
move.quantity_done = self.lines_qty
else:
# Auto-fill all lines as done
for ml in move.move_line_ids:
ml.qty_done = ml.reserved_uom_qty
move._recompute_state()
move.mapped("picking_id")._compute_state()
return {}