[Erp5-report] r42684 jm - /erp5/trunk/products/ERP5/mixin/amount_generator.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 26 14:38:11 CET 2011


Author: jm
Date: Wed Jan 26 14:38:11 2011
New Revision: 42684

URL: http://svn.erp5.org?rev=42684&view=rev
Log:
amount_generator: really treat price=0 (on model line) as 0 (instead of default 1)

Modified:
    erp5/trunk/products/ERP5/mixin/amount_generator.py

Modified: erp5/trunk/products/ERP5/mixin/amount_generator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/amount_generator.py?rev=42684&r1=42683&r2=42684&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/amount_generator.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/amount_generator.py [utf8] Wed Jan 26 14:38:11 2011
@@ -288,10 +288,10 @@ class AmountGeneratorMixin:
         # (XXX is it OK ?) XXX-JPS Need careful review with taxes
         quantity = float(sum(map(base_amount.getGeneratedAmountQuantity,
                                  base_application_set)))
-        try:
-          quantity *= property_dict.pop('quantity', 1)
-        except TypeError: # None or ''
-          pass
+        for key in 'quantity', 'price', 'efficiency':
+          if property_dict.get(key, 0) in (None, ''):
+            del property_dict[key]
+        quantity *= property_dict.pop('quantity', 1)
         if not (quantity or generate_empty_amounts):
           continue
         # Backward compatibility
@@ -319,8 +319,8 @@ class AmountGeneratorMixin:
           amount = getRoundingProxy(amount, context=self)
         result.append(amount)
         # Contribute
-        quantity *= (property_dict.get('price') or 1) / \
-                    (property_dict.get('efficiency') or 1)
+        quantity *= property_dict.get('price', 1) / \
+                    property_dict.get('efficiency', 1)
         for base_contribution in property_dict['base_contribution_set']:
           base_amount.contribute(base_contribution, quantity)
 



More information about the Erp5-report mailing list