Merge PR #1179 into 16.0

Signed-off-by dreispt
This commit is contained in:
OCA-git-bot
2024-03-02 16:01:34 +00:00

View File

@@ -14,11 +14,21 @@ class StockMove(models.Model):
# For rather unlikely occassions where linked production is not in the right
# state.
for move in moves_with_no_check:
production_move = self.search([("move_dest_ids", "=", move.id)])
production = production_move.production_id
if production.reservation_state != "assigned":
production.action_assign()
if production.reservation_state == "assigned":
production_moves = self.search(
[
("move_dest_ids", "=", move.id),
("state", "not in", ("done", "cancel")),
]
)
productions = production_moves.production_id
unassigned_productions = productions.filtered(
lambda p: p.reservation_state != "assigned"
)
unassigned_productions.action_assign()
if all(
state == "assigned"
for state in unassigned_productions.mapped("reservation_state")
):
continue
moves_with_no_check -= move
res = super(StockMove, self - moves_with_no_check)._action_done(