Skip to content
Snippets Groups Projects
Commit c347f679 authored by Donatas's avatar Donatas
Browse files

[FIX] purchase_stock: PO line related stock moves getting stuck


When purchase order line is removed, related stock moves procure method stays as "Advanced" which doesn't allow reservation from stock

closes odoo/odoo#70643

X-original-commit: a474108d
Signed-off-by: default avatarWilliam Henrotin <Whenrow@users.noreply.github.com>
parent 29a9cf98
No related branches found
No related tags found
No related merge requests found
......@@ -340,6 +340,18 @@ class PurchaseOrderLine(models.Model):
self.filtered(lambda l: l.order_id.state == 'purchase')._create_or_update_picking()
return result
def unlink(self):
self.move_ids._action_cancel()
ppg_cancel_lines = self.filtered(lambda line: line.propagate_cancel)
ppg_cancel_lines.move_dest_ids._action_cancel()
not_ppg_cancel_lines = self.filtered(lambda line: not line.propagate_cancel)
not_ppg_cancel_lines.move_dest_ids.write({'procure_method': 'make_to_stock'})
not_ppg_cancel_lines.move_dest_ids.recompute_state()
return super().unlink()
# --------------------------------------------------
# Business methods
# --------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment