Commit a4556745 authored by Lucas Carvalho's avatar Lucas Carvalho

Fixed bugs.

When you are editing the Shopping Cart without shipping service or with a shipping service without price.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28418 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b8f9ecb7
......@@ -202,36 +202,40 @@ request = context.REQUEST\n
translateString = context.Base_translateString \n
quantity = field_my_buy_quantity\n
shipping_method = field_my_shipping_method\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList(include_shipping = True)\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList(include_shipping=True)\n
shopping_cart_products_items = filter(lambda x: x.getId()!=\'shipping_method\', shopping_cart_items)\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
\n
# handle change in quantity for shopping items\n
if quantity is not None:\n
## when we have one item in shoppping cart we get \n
## quantity as a string rather as a list\n
# when we have one item in shoppping cart we get \n
# quantity as a string rather as a list\n
if isinstance(quantity, str):\n
quantity = [quantity]\n
\n
counter = 0\n
for order_line in shopping_cart_products_items:\n
new_quantity = int(quantity[counter])\n
if new_quantity>=1:\n
order_line.setQuantity(new_quantity)\n
else:\n
## remove it from shopping cart\n
# remove it from shopping cart\n
shopping_cart.manage_delObjects(order_line.getId())\n
counter += 1\n
\n
## handle shipping\n
if shipping_method is not None:\n
# handle shipping\n
order_line = getattr(shopping_cart, \'shipping_method\', None)\n
if shipping_method not in [\'\', None]:\n
shipping = context.getPortalObject().restrictedTraverse(shipping_method)\n
order_line = getattr(shopping_cart, \'shipping_method\', None)\n
if order_line is None:\n
## create new shipping method order line\n
# create new shipping method order line\n
order_line = shopping_cart.newContent(id=\'shipping_method\', portal_type=\'Sale Order Line\')\n
## .. and update it\n
# .. and update it\n
order_line.setResource(shipping.getRelativeUrl())\n
order_line.setQuantity(1)\n
else:\n
if field_my_shipping_method in [\'\', None] and order_line is not None:\n
shopping_cart.manage_delObjects(order_line.getId())\n
\n
context.Base_redirect(\'SaleOrder_viewAsWeb\', \\\n
keep_items={\'portal_status_message\': translateString("Your cart was successfuly updated.", mapping = dict())})\n
......@@ -307,8 +311,8 @@ context.Base_redirect(\'SaleOrder_viewAsWeb\', \\\n
<string>_getitem_</string>
<string>new_quantity</string>
<string>_inplacevar_</string>
<string>shipping</string>
<string>getattr</string>
<string>shipping</string>
<string>dict</string>
</tuple>
</value>
......
......@@ -69,7 +69,8 @@ total = 0.0\n
shopping_cart_items = context.SaleOrder_getShoppingCartItemList(include_shipping)\n
for order_line in shopping_cart_items:\n
resource = context.restrictedTraverse(order_line.getResource())\n
total += order_line.getPrice() * order_line.getQuantity()\n
if order_line.getPrice() is not None:\n
total += order_line.getPrice() * order_line.getQuantity()\n
\n
# XXX: CHECK if we have to include taxes on shipping service\n
if include_taxes:\n
......@@ -137,9 +138,9 @@ else:\n
<string>_getiter_</string>
<string>order_line</string>
<string>resource</string>
<string>None</string>
<string>_inplacevar_</string>
<string>tax_info</string>
<string>None</string>
<string>tax_name</string>
<string>tax_percent</string>
<string>currency</string>
......
......@@ -311,7 +311,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\', \'\')] + [( \'%s - %s %s\' %(o.getObject().getTitle(), o.getObject().getPrice(), here.SaleOrder_getShoppingCartDefaultCurrency().getTitle() ), o.getObject().getRelativeUrl(),) for o in here.SaleOrder_getAvailableShippingResourceList()]</string> </value>
<value> <string>python: [(\'\', \'\')] + [( \'%s - %s %s\' %(o.getObject().getTitle(), o.getObject().getPrice(), here.SaleOrder_getShoppingCartDefaultCurrency().getTitle() ), o.getObject().getRelativeUrl(),) for o in here.SaleOrder_getAvailableShippingResourceList() if o.getObject().getPrice() is not None]</string> </value>
</item>
</dictionary>
</pickle>
......
155
\ No newline at end of file
147
\ 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