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

Handle payment mode and comments through accessors

Also improved comments and docstring including TODO.
parent ed22430e
......@@ -189,10 +189,14 @@
<value> <string encoding="cdata"><![CDATA[
"""\n
Update shopping cart by change items quantity and setting preferred \n
shipping.\n
"""\n
Update shopping cart by changing item quantities and by setting preferred\n
shipping method and payment method.\n
\n
TODO:\n
- support modern payment conditions (instead of payment_mode)\n
- use Base_edit and a real ERP5 Form in order to benefit from\n
field reusability and property validation\n
"""\n
request = context.REQUEST\n
translateString = context.Base_translateString \n
quantity = field_my_buy_quantity\n
......@@ -201,10 +205,10 @@ shopping_cart_items = context.SaleOrder_getShoppingCartItemList(include_shipping
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
# 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
# Whenever there is onlu one item in shoppping cart, quantity\n
# is a string rather as a list\n
if isinstance(quantity, str):\n
quantity = [quantity]\n
\n
......@@ -214,11 +218,11 @@ if quantity is not None:\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
# 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
......@@ -232,7 +236,11 @@ 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
return context.SaleOrder_paymentRedirect(field_my_comment, field_my_payment_mode)\n
# Handle payment mode and comment\n
shopping_cart.setComment(field_my_comment)\n
shopping_cart.setPaymentConditionPaymentMode(field_my_payment_mode) # XXX This is bad because it does not use trade conditions XXX\n
\n
return context.SaleOrder_paymentRedirect()\n
]]></string> </value>
......
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