Commit 50aff0b5 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

Minor optimizations and comments

Enable SaleOrder_isShippingRequired implementation
Optimize SaleOrder_isShoppingCartEmpty
parent b22aceb8
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Return the default trade condition for thie ecommerce site\n Return the default trade condition for thie ecommerce site\n
\n
TODO:\n
- (rafael) This script should be removed or turned into a preference at least.\n
\n
"""\n """\n
default = "sale_trade_condition_module/default_trade_condition"\n default = "sale_trade_condition_module/default_trade_condition"\n
\n \n
...@@ -72,7 +76,7 @@ return context.getPortalObject().restrictedTraverse(default)\n ...@@ -72,7 +76,7 @@ return context.getPortalObject().restrictedTraverse(default)\n
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Return default trade condition</string> </value> <value> <string>DEPRECATED</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -58,8 +58,9 @@ ...@@ -58,8 +58,9 @@
- implement generic pretty printing of currencies\n - implement generic pretty printing of currencies\n
"""\n """\n
price_currency_title = context.getPriceCurrencyTitle()\n price_currency_title = context.getPriceCurrencyTitle()\n
if price_currency_title == "Euro": price_currency_title = "€"\n if price_currency_title == "Euro": \n
return \'%s %s\' %(context.getTotalPrice(), price_currency_title)\n price_currency_title = "€"\n
return \'%0.2f %s\' % (context.getTotalPrice(), price_currency_title)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -193,8 +193,8 @@ shopping_cart = context.SaleOrder_getShoppingCart()\n ...@@ -193,8 +193,8 @@ shopping_cart = context.SaleOrder_getShoppingCart()\n
shipping_method = getattr(shopping_cart, \'shipping_method\', None)\n shipping_method = getattr(shopping_cart, \'shipping_method\', None)\n
if shipping_method is not None:\n if shipping_method is not None:\n
return shipping_method.getResourceValue()\n return shipping_method.getResourceValue()\n
else:\n \n
return None\n return None\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -78,7 +78,7 @@ if include_taxes:\n ...@@ -78,7 +78,7 @@ if include_taxes:\n
\n \n
if include_currency:\n if include_currency:\n
currency = web_site.WebSite_getShoppingCartDefaultCurrency()\n currency = web_site.WebSite_getShoppingCartDefaultCurrency()\n
return \'%s %s\' %(total, currency.getReference())\n return \'%s %s\' % (total, currency.getReference())\n
else:\n else:\n
return str(total)\n return str(total)\n
</string> </value> </string> </value>
......
...@@ -195,15 +195,15 @@ ...@@ -195,15 +195,15 @@
- use ERP5 constrain framework checkConsistency/fixConsistency\n - use ERP5 constrain framework checkConsistency/fixConsistency\n
in order to be perfectly generic\n in order to be perfectly generic\n
\'\'\'\n \'\'\'\n
return False\n #return False\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList()\n shopping_cart_items = context.SaleOrder_getShoppingCartItemList()\n
\n \n
weight = 0\n
for order_line in shopping_cart_items:\n for order_line in shopping_cart_items:\n
resource = order_line.getResourceValue()\n resource = order_line.getResourceValue()\n
weight += resource.getBaseWeight(0)\n if resource.getBaseWeight(0) > 0:\n
return True\n
\n \n
return weight > 0\n return False\n
]]></string> </value> ]]></string> </value>
......
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
- add log for "should never happen case" so that we can\n - add log for "should never happen case" so that we can\n
make sure this case does not happen on public site\n make sure this case does not happen on public site\n
anymore\n anymore\n
- rename script to SaleOrder_isShoppingCartUserConsistent\n
"""\n """\n
result = True\n result = True\n
\n \n
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
TODO:\n TODO:\n
- make sure this script is not called more than once per page\n - make sure this script is not called more than once per page\n
"""\n """\n
if context.REQUEST.get(\'session_id\', None) is None:\n
return True\n
return len(context.SaleOrder_getShoppingCartItemList())==0\n return len(context.SaleOrder_getShoppingCartItemList())==0\n
</string> </value> </string> </value>
</item> </item>
......
302 303
\ No newline at end of file \ No newline at end of file
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