[Erp5-report] r19280 - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplateItem/p...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 12 17:15:40 CET 2008


Author: alex
Date: Tue Feb 12 17:15:40 2008
New Revision: 19280

URL: http://svn.erp5.org?rev=19280&view=rev
Log:
* using a "hard" filter on portal_type was not a good solution, use a better sort method instead.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Movement_getPriceCalculationOperandDict.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Movement_getPriceCalculationOperandDict.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Movement_getPriceCalculationOperandDict.xml?rev=19280&r1=19279&r2=19280&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Movement_getPriceCalculationOperandDict.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Movement_getPriceCalculationOperandDict.xml Tue Feb 12 17:15:40 2008
@@ -65,21 +65,56 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>portal_type_list = None\n
-\n
-explanation = context.getExplanationValue()\n
-if explanation is not None:\n
-  explanation_type = explanation.getPortalType()\n
-# XXX FIXME: Hardcoded values\n
-  if "Purchase" in explanation_type:\n
-    portal_type_list = ("Purchase Supply Line", "Purchase Supply Cell", "Supply Line", "Supply Cell")\n
-  elif "Sale" in explanation_type:\n
-    portal_type_list = ("Sale Supply Line", "Sale Supply Cell", "Supply Line", "Supply Cell")\n
+            <value> <string>def sourceSortMethod(a, b):\n
+  if a.getSource():\n
+    return -1 # a defines a source and wins\n
+  return 1 # a defines no source ans loses\n
+\n
+def destinationSortMethod(a, b):\n
+  if a.getDestination():\n
+    return -1 # a defines a destination and wins\n
+  return 1 # a defines no destination ans loses\n
+\n
+def resourcePurchasePriceSortMethod(a, b):\n
+   if "Purchase" in a.getPortalType():\n
+     if "Purchase" in b.getPortalType():\n
+       return sourceSortMethod(a, b)\n
+     else:\n
+       return -1\n
+   else:\n
+     if "Purchase" in b.getPortalType():\n
+       return 1\n
+     else:\n
+       return destinationSortMethod(a, b)\n
+\n
+def resourceSalePriceSortMethod(a, b):\n
+   if "Sale" in a.getPortalType():\n
+     if "Sale" in b.getPortalType():\n
+       return destinationSortMethod(a, b)\n
+     else:\n
+       return -1\n
+   else:\n
+     if "Sale" in b.getPortalType():\n
+       return 1\n
+     else:\n
+       return sourceSortMethod(a, b)\n
+\n
+try:\n
+  explanation = context.getExplanationValue()\n
+except:\n
+  pass\n
+else:\n
+  if explanation is not None:\n
+    explanation_type = explanation.getPortalType()\n
+    # XXX FIXME: Hardcoded values\n
+    if "Purchase" in explanation_type:\n
+      kw[\'sort_method\'] = resourcePurchasePriceSortMethod\n
+    elif "Sale" in explanation_type:\n
+      kw[\'sort_method\'] = resourceSalePriceSortMethod\n
 \n
 resource = context.getResourceValue()\n
 if resource is not None:\n
-  return resource.getPriceCalculationOperandDict(default=default, context=context,\n
-      portal_type_list=portal_type_list, **kw)\n
+  return resource.getPriceCalculationOperandDict(default=default, context=context, **kw)\n
 else:\n
   return default\n
 </string> </value>
@@ -132,12 +167,16 @@
                           <tuple>
                             <string>default</string>
                             <string>kw</string>
-                            <string>None</string>
-                            <string>portal_type_list</string>
+                            <string>sourceSortMethod</string>
+                            <string>destinationSortMethod</string>
+                            <string>resourcePurchasePriceSortMethod</string>
+                            <string>resourceSalePriceSortMethod</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>explanation</string>
+                            <string>None</string>
                             <string>explanation_type</string>
+                            <string>_write_</string>
                             <string>resource</string>
                             <string>_apply_</string>
                           </tuple>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=19280&r1=19279&r2=19280&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision Tue Feb 12 17:15:40 2008
@@ -1,1 +1,1 @@
-699
+703




More information about the Erp5-report mailing list