From 2b4a50aadafbd277bcc898dd9c4da529b3336d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 6 Nov 2009 17:43:41 +0000 Subject: [PATCH] Use an alternate way of testing quantity when delivery quantity is 0. For example one simulation movement quantity -1 and another simulation movement of quantity 1 that becomes one delivery movement of quantity 0. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30378 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../ERP5/Document/QuantityDivergenceTester.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/product/ERP5/Document/QuantityDivergenceTester.py b/product/ERP5/Document/QuantityDivergenceTester.py index 36b8682f06..3bcd3ccc4f 100644 --- a/product/ERP5/Document/QuantityDivergenceTester.py +++ b/product/ERP5/Document/QuantityDivergenceTester.py @@ -104,8 +104,28 @@ class QuantityDivergenceTester(PropertyDivergenceTester): if delivery_ratio == 0 and quantity > 0: return [message] - if not self.compare(d_quantity, quantity): - return [message] + if d_quantity != 0.0: + if not self.compare(d_quantity, quantity): + return [message] + else: + # A delivery quantity of 0 is an exceptional case that we cannot really + # handle with the current approach of delivery ratio. + d_quantity = delivery.getQuantity() + quantity = sum([m.getCorrectedQuantity() for m in + delivery.getDeliveryRelatedValueList( + portal_type='Simulation Movement')]) + + if not self.compare(d_quantity, quantity): + return [DivergenceMessage( + object_relative_url= delivery.getRelativeUrl(), + divergence_scope='quantity', + simulation_movement = simulation_movement, + decision_value = d_quantity , + prevision_value = quantity, + tested_property='quantity', + message='Quantity', + **extra_parameters)] + return [] def compare(self, x, y): -- 2.30.9