From e8fea60bb899b8c7dbdbae43bc53de9ba4248dd9 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 12 Jan 2021 09:31:45 +0000 Subject: [PATCH] [FIX] purchase_requisition: Purchase Order Approval Steps to reproduce the bug: - Create a user with only access rights, Inventory = Administrator, Purchase = user - Enable feature Purchase order approval in Purchase > Settings - Agreement Type = Exclusive, lines of Agreement, Quantity of Agreement - Login as a new created user and navigate to a menu Purchase > Purchase agreement and create a new Purchase agreement, confirm it - From the button create two PO (having a total > 5000) - Cancel one of the PO first and try to approve another one Bug: A UserError was riased: You have to cancel or validate every RFQ before closing the purchase requisition. opw:2368999 closes odoo/odoo#64431 X-original-commit: dfee34b0b9c83beca9aca0b21e7f130ae86c0ee6 Signed-off-by: Simon Goffin (sig) --- addons/purchase_requisition/models/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase_requisition/models/purchase.py b/addons/purchase_requisition/models/purchase.py index 7c7e2e6f1dd..6af1f3f0cb3 100644 --- a/addons/purchase_requisition/models/purchase.py +++ b/addons/purchase_requisition/models/purchase.py @@ -84,7 +84,8 @@ class PurchaseOrder(models.Model): if po.requisition_id.type_id.exclusive == 'exclusive': others_po = po.requisition_id.mapped('purchase_ids').filtered(lambda r: r.id != po.id) others_po.button_cancel() - po.requisition_id.action_done() + if po.state not in ['draft', 'sent', 'to approve']: + po.requisition_id.action_done() return res @api.model