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

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 22 19:52:00 CET 2010


Author: jm
Date: Mon Mar 22 19:51:58 2010
New Revision: 33967

URL: http://svn.erp5.org?rev=33967&view=rev
Log:
amount_generator: add _getResourceAmountAggregateKey method

This will allow Transformed Resource to merge cells.

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=33967&r1=33966&r2=33967&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/amount_generator.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/amount_generator.py [utf8] Mon Mar 22 19:51:58 2010
@@ -98,6 +98,31 @@
           # so that it is possible to create models based
           # on the weight in tons
       )
+
+  def _getResourceAmountAggregateKey(self, amount_generator_cell):
+    """Define a key in order to aggregate amounts
+
+      Transformed Resource (Transformation)
+        key must be None because:
+          - quantity and variation are defined in different cells so that the
+            user does not need to enter values depending on all axes
+          - amount_generator_cell.test should filter only 1 variant
+        current key = (acquired resource, acquired variation)
+
+      Assorted Resource (Transformation)
+        key = (assorted resource, assorted resource variation)
+        usually resource and quantity provided together
+
+      Payroll
+
+        key = (payroll resource, payroll resource variation)
+
+      Tax
+
+        key = (tax resource, tax resource variation)
+    """
+    return (amount_generator_cell.getResource(),
+            amount_generator_cell.getVariationText()) # Variation UID, Hash ?
 
   security.declareProtected(Permissions.AccessContentsInformation,
                             'getGeneratedAmountList')
@@ -185,28 +210,7 @@
           resource = amount_generator_cell.getResource()
           # Case 1: the cell defines a final amount of resource
           if resource:
-            # Define a key in order to aggregate amounts
-            #   in transformations where variation and quantity
-            #   are defined in different cells
-            #
-            # Transformed Resource (Transformation)
-            #   key = anything (only one cell selected)
-            #   current key = (acquired resource, acquired variation)
-            #
-            # Assorted Resource (Transformation)
-            #   key = (assorted resource, assorted resource variation)
-            #   usually resource and quantity provided together
-            #
-            # Payroll
-            #
-            #   key = (payroll resource, payroll resource variation)
-            #
-            # Tax
-            #
-            #   key = (tax resource, tax resource variation)
-            key = (amount_generator_cell.getResource(),
-                    # Variation UID, Hash ?
-                   amount_generator_cell.getVariationText())
+            key = self._getResourceAmountAggregateKey(amount_generator_cell)
             property_dict = resource_amount_aggregate.setdefault(key, {})
             # Then collect the mapped properties (net_converted_quantity,
             # resource, quantity, base_contribution_list, base_application...)




More information about the Erp5-report mailing list