[Erp5-report] r35104 yo - /erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 7 13:49:15 CEST 2010


Author: yo
Date: Fri May  7 13:49:15 2010
New Revision: 35104

URL: http://svn.erp5.org?rev=35104&view=rev
Log:
Separate a piece of code specific to each rule to a new method. In addition, make it extract a use category as well.

Modified:
    erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py

Modified: erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py?rev=35104&r1=35103&r2=35104&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py [utf8] (original)
+++ erp5/trunk/products/ERP5Legacy/Document/TradeModelRule.py [utf8] Fri May  7 13:49:15 2010
@@ -47,6 +47,14 @@
   def _isBPM(self):
     return True
 
+  def _getExpandableAmountPropertyDict(self, amount):
+    """Return a dict of properties extracted from an amount."""
+    d = {}
+    for property in ('price', 'resource_list', 'reference', 'quantity',
+                     'base_application_list', 'base_contribution_list', 'use'):
+      d[property] = amount.getProperty(property)
+    return d
+
   def _generatePrevisionList(self, applied_rule, **kw):
     """Generates list of movements (as dicts), and let parent class to decide
     which is to add, modify or delete"""
@@ -69,19 +77,10 @@
         business_path = business_path_list[0]
       else:
         business_path = None
+
       movement_kw = self._getExpandablePropertyDict(applied_rule,
         context_movement, business_path)
-
-      # rule specific
-      movement_kw['price'] = amount.getProperty('price')
-      movement_kw['resource_list'] = amount.getProperty('resource_list')
-      movement_kw['reference'] = amount.getProperty('reference')
-      movement_kw['quantity'] = amount.getProperty('quantity')
-      movement_kw['base_application_list'] = amount.getProperty(
-          'base_application_list')
-      movement_kw['base_contribution_list'] = amount.getProperty(
-          'base_contribution_list')
-
+      movement_kw.update(self._getExpandableAmountPropertyDict(amount))
       movement_list.append(movement_kw)
 
     return movement_list




More information about the Erp5-report mailing list