[IMP] stock_request_purchase: Add context key to skip cancel purchase

TT50450
This commit is contained in:
Víctor Martínez
2024-08-09 15:38:34 +02:00
parent c6320d410b
commit 93ac540b58

View File

@@ -42,10 +42,11 @@ class StockRequest(models.Model):
def action_cancel(self):
"""Propagate the cancellation to the generated purchase orders."""
res = super().action_cancel()
self.sudo().purchase_ids.filtered(
lambda x: x.state not in ("purchase", "done", "cancel")
and x.stock_request_ids == self
).button_cancel()
if not self.env.context.get("skip_cancel_po_from_stock_request"):
self.sudo().purchase_ids.filtered(
lambda x: x.state not in ("purchase", "done", "cancel")
and x.stock_request_ids == self
).button_cancel()
return res
def action_view_purchase(self):