From 1e842901a00baa1cf9aa0c4a6cb165ebe598ae47 Mon Sep 17 00:00:00 2001 From: "Matheus Leal Viana (malv)" Date: Thu, 13 Jul 2023 13:12:02 +0000 Subject: [PATCH] [FIX] purchase_requisition_stock: calculate on-time rate when percentage is zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Versions: --------- - 16.0 Steps to reproduce: ------------------- - Create a new Purchase Order. - Set the Vendor to a brand new contact. - Add a product that would be delivered. - Confirm the PO, set the Expected delivery date in the past. - Notice that on_time_rate and on_time_rate_perc are both -1. - Process the delivery. - Now on_time_rate is 0 but on_time_rate_perc is -1 still! Issue: ------ The field OTD is -1 even when On-time delivery is 0 Cause: ------ The issue is happening because if po.on_time_rate == 0 the value Is set to -1. Solution: --------- Modify the condition to ‘po.on_time_rate >= 0’ to handle this case OPW-3413668 closes odoo/odoo#128584 X-original-commit: 4e3bf2242808435fd13be323af535cc6cc816da3 Signed-off-by: Adrien Widart (awt) Signed-off-by: Matheus Leal Viana (malv) --- addons/purchase_requisition_stock/models/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase_requisition_stock/models/purchase.py b/addons/purchase_requisition_stock/models/purchase.py index 14b12534bf5..547eb4c6581 100644 --- a/addons/purchase_requisition_stock/models/purchase.py +++ b/addons/purchase_requisition_stock/models/purchase.py @@ -12,7 +12,7 @@ class PurchaseOrder(models.Model): @api.depends('on_time_rate') def _compute_on_time_rate_perc(self): for po in self: - if po.on_time_rate > 0: + if po.on_time_rate >= 0: po.on_time_rate_perc = po.on_time_rate / 100 else: po.on_time_rate_perc = -1