[Erp5-report] r24879 - in /erp5/trunk/bt5/erp5_base: SkinTemplateItem/portal_skins/erp5_bas...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Dec 12 16:20:32 CET 2008


Author: mame
Date: Fri Dec 12 16:20:27 2008
New Revision: 24879

URL: http://svn.erp5.org?rev=24879&view=rev
Log:
2008-12-12 mame
*add script to convert currency exchange line into predicates
* modify script so that if no base price is found on predicate, skip it

Added:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml
Modified:
    erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml
    erp5/trunk/bt5/erp5_base/bt/revision

Added: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml?rev=24879&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml (added)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml [utf8] Fri Dec 12 16:20:27 2008
@@ -1,0 +1,132 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>start_date = context.getStartDate()\n
+stop_date = context.getStopDate()\n
+identity_criterion = {\'start_date\':(start_date,stop_date)}\n
+return context.asContext(_range_criterion=identity_criterion,\n
+                         membership_criterion_base_category=[\'price_currency\',\'resource\'],\n
+                         membership_criterion_category=[\'resource/%s\' % context.getParentValue().getRelativeUrl(),\n
+                                                        \'price_currency/%s\' % context.getPriceCurrency()])\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>**kw</string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>kw</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>start_date</string>
+                            <string>stop_date</string>
+                            <string>identity_criterion</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>CurrencyExchangeLine_asPredicate</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml?rev=24879&r1=24878&r2=24879&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml [utf8] Fri Dec 12 16:20:27 2008
@@ -53,7 +53,9 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""\n
+            <value> <string encoding="cdata"><![CDATA[
+
+"""\n
 Search for all predicates that corresponds to this particular context\n
 and returns the base price of the resource\n
 This script derives form getPriceCalculationOperandDict and is invoked by getPrice.\n
@@ -63,18 +65,34 @@
   **kw -- dictionary containing all information of the transaction\n
 \n
 """\n
+\n
+def sort_by_date(a, b):\n
+  if a.getStartDateRangeMin() > b.getStartDateRangeMin() :\n
+    return -1\n
+  return 1\n
+\n
 #If getPrice is directly called on a resource, call directly\n
 #Resource_getPriceCalculationOperandDict on the resource\n
 if movement is None:\n
   return context.Resource_getPriceCalculationOperandDict(**kw)\n
 else:\n
   predicate_list = context.portal_domains.searchPredicateList(\n
-                 context=movement,portal_type=\'Currency Exchange Line\')\n
+                 context=movement,\n
+            portal_type=\'Currency Exchange Line\',\n
+                validation_state=\'validated\',\n
+                test =1,\n
+                 sort_method=sort_by_date,**kw )\n
+  \n
+ \n
+\n
 # For each predicate(i.e: Currency Exchange Line) found, get the exchange rate\n
 # with the reference currency\n
   for predicate in predicate_list:\n
-     return predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw)\n
-</string> </value>
+     if predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw) is not None:\n
+       return predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw)\n
+
+
+]]></string> </value>
         </item>
         <item>
             <key> <string>_code</string> </key>
@@ -114,6 +132,7 @@
                             <string>movement</string>
                             <string>REQUEST</string>
                             <string>kw</string>
+                            <string>sort_by_date</string>
                             <string>None</string>
                             <string>_apply_</string>
                             <string>_getattr_</string>

Modified: erp5/trunk/bt5/erp5_base/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_base/bt/revision?rev=24879&r1=24878&r2=24879&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_base/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_base/bt/revision [utf8] Fri Dec 12 16:20:27 2008
@@ -1,1 +1,1 @@
-491
+499




More information about the Erp5-report mailing list