Commit 4d524da9 authored by Jean-Paul Smets's avatar Jean-Paul Smets Committed by Xiaowu Zhang

Add price context script

This script creates a context to compute the default price of a product in the online store in line with extended getPrice API
parent e8762ef2
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>"""\n
Create a temporary movement with properties and categories\n
needed to provide a default price for a given resource\n
\n
TODO:\n
- support input parameters (**kw) to specialize\n
price calculation\n
"""\n
from Products.ERP5Type.Document import newTempMovement\n
\n
web_site_value = context.getPortalObject().web_site_module.weinparis # hack cause no way to know default site....\n
variation_dict = {}\n
if len(context.getVariationRangeCategoryList()):\n
request = context.REQUEST\n
# Set each category of variation either to the default value\n
# or to the value provided by the REQUEST object\n
for variation_base_category in context.getVariationBaseCategoryList():\n
default_variation = context.getVariationCategoryList(base_category_list=[variation_base_category])\n
# circumvent inconsistency for individual variations\n
default_variation = default_variation or \\\n
context.getVariationRangeCategoryList(base_category_list=[variation_base_category])\n
if len(default_variation):\n
default_variation = default_variation[0]\n
variation_category = request.get(variation_base_category, default_variation)\n
variation_dict[variation_base_category] = variation_category\n
movement = newTempMovement(context, "temp_pricing_movement", resource_value=context,\n
price_currency_value=web_site_value.WebSite_getShoppingCartDefaultCurrency(),\n
**variation_dict)\n
return movement\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Resource_getPriceCalculationDefaultContext</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment