diff options
| author | Donatas <donatas@vialaurea.lt> | 2021-05-04 09:44:19 +0000 |
|---|---|---|
| committer | Donatas <donatas@vialaurea.lt> | 2021-05-11 09:06:32 +0000 |
| commit | c347f679d6a635428b12ffa04b5e16b4f2d3d78f (patch) | |
| tree | cb31617928789c9ff15706b6cbcbe99f29c8a013 | |
| parent | 29a9cf981729cfe8e55caaadf6bf14a8a4a7708e (diff) | |
[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: a474108d0d7ea70506e8871d3fd226e2a7b5f36c
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
| -rw-r--r-- | addons/purchase_stock/models/purchase.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index 1a3c4987b0c..c6ebda99811 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -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 # -------------------------------------------------- |
