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