diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml new file mode 100644 index 0000000000000000000000000000000000000000..f95f506565e298c01496a4d6350fb91b67af9108 --- /dev/null +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchangeLine_asPredicate.xml @@ -0,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> diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml index e9cef383f2cb3b6320488b86a7c61bcb524300a5..721e41d2f9d926cf29cc734c5f139903c73ffb6f 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Currency_getPriceCalculationOperandDict.xml @@ -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 @@ This script derives form getPriceCalculationOperandDict and is invoked by getPri **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 @@ else:\n <string>movement</string> <string>REQUEST</string> <string>kw</string> + <string>sort_by_date</string> <string>None</string> <string>_apply_</string> <string>_getattr_</string> diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 5c84cf6fdb5b07f53ee2531098812526ca2011d4..9889789bab1da77ed31cb074af6a29a69425f266 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -491 \ No newline at end of file +499 \ No newline at end of file