Commit 79dde5cb authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_advanced_ecommerce: fix issue

1. can't remove promotional code
2. update shipment when add new one
3. put discount under tax
4. customize for shipment
parent ec4dabb5
......@@ -115,12 +115,20 @@ if not line_found:
additional_order_line = shopping_cart.newContent(portal_type='Sale Order Line')
additional_order_line.setResource(additional_service_value.getRelativeUrl())
additional_order_line.setQuantity(additional_service_quantity * quantity)
additional_order_line.setBaseContributionList(resource.getBaseContributionList())
tmp_contribution_list = resource.getBaseContributionList()
if 'base_amount/shop/discounted/coupon' in tmp_contribution_list:
tmp_contribution_list.remove('base_amount/shop/discounted/coupon')
additional_order_line.setBaseContributionList(tmp_contribution_list)
additional_order_line.setPrice(additional_service_value.getPrice(supply_path_type=["Sale Supply Line", "Sale Supply Cell"], context=additional_order_line))
# set aggregate so we know it's who's additional service
additional_order_line.setAggregate(variation or context.getRelativeUrl())
shopping_cart.edit(promotional_code=promotional_code)
shipping_line = getattr(shopping_cart, 'shipping_method', None)
if shipping_line is not None:
shopping_cart.manage_delObjects(shipping_line.getId())
context.WebSection_updateShoppingCartTradeCondition(shopping_cart, None, promotional_code=promotional_code)
context.getPortalObject().portal_sessions[session_id].update(shopping_cart=shopping_cart)
......
......@@ -5,12 +5,24 @@
portal = context.getPortalObject()
only_small_product = False
la_poste = True
if only_small_product:
shipping_product_line_category_uid = portal.portal_categories.product_line.shipping.ship_small_product.getUid()
shopping_cart = context.SaleOrder_getShoppingCart()
#XXXXXXXXXXXXXXXX very bad
for i in shopping_cart.objectValues(portal_type='Sale Order Line'):
if i.getId() == 'shipping_method':
continue
if i.getResource() != 'product_module/520':
la_poste = False
break
if la_poste:
shipping_product_line_category_uid = portal.portal_categories.product_line.shipping.la_poste.getUid()
else:
shipping_product_line_category_uid = [x.getUid() for x in portal.portal_categories.product_line.shipping.contentValues() if x.getId() != 'ship_small_product']
shipping_product_line_category_uid = [x.getUid() for x in portal.portal_categories.product_line.shipping.contentValues() if x.getId() != 'la_poste']
return [r.getObject() for r in portal.portal_catalog(
......
return round(sum([i.getTotalPrice() for i in context.getAggregatedAmountList(rounding=True) if "base_amount/shop/discounted/coupon" in i.getBaseApplicationList()]), 2)
return round(sum([i.getTotalPrice() for i in context.getAggregatedAmountList() if "base_amount/shop/discounted/coupon" in i.getBaseApplicationList()]), 2)
......@@ -51,17 +51,6 @@
</td></tr>
</tal:block>
<tal:block tal:condition = "python: not empty_cart and discount < 0">
<tr><td class="cart_middle">
<div class="cart_left">
<span tal:replace="python: here.Base_translateString('Discount')"/>
</div>
<div class="cart_right">
<span tal:replace="discount"/> <span tal:replace="currency_symbol"/>
</div>
</td></tr>
</tal:block>
<tal:block tal:condition = "python: not empty_cart">
<tr><td class="cart_middle">
<div class="cart_left">
......@@ -85,6 +74,17 @@
</td></tr>
</tal:block>
<tal:block tal:condition = "python: not empty_cart and discount < 0">
<tr><td class="cart_middle">
<div class="cart_left">
<span tal:replace="python: here.Base_translateString('Discount')"/>
</div>
<div class="cart_right">
<span tal:replace="discount"/> <span tal:replace="currency_symbol"/>
</div>
</td></tr>
</tal:block>
<tal:block tal:condition = "not: empty_cart">
<tr><td class="cart_middle">
<div class="cart_left">
......
......@@ -59,7 +59,8 @@ if field_my_shipping_method not in ['', None]:
if field_my_comment is not None:
shopping_cart.setComment(field_my_comment)
context.WebSection_updateShoppingCartTradeCondition(shopping_cart, field_my_payment_mode, preserve=True)
promotional_code = getattr(shopping_cart, 'promotional_code', '')
context.WebSection_updateShoppingCartTradeCondition(shopping_cart, field_my_payment_mode, preserve=True, promotional_code=promotional_code)
portal.portal_sessions[container.REQUEST['session_id']].update(shopping_cart=shopping_cart)
......
......@@ -7,8 +7,7 @@ if promotional_code:
shopping_cart.setSpecialiseValue(trade_condition)
else:
if not shopping_cart.getSpecialise():
shopping_cart.setSpecialise(context.WebSection_getDefaultTradeCondition())
shopping_cart.setSpecialise(context.WebSection_getDefaultTradeCondition())
portal = context.getPortalObject()
portal.portal_sessions[container.REQUEST['session_id']].update(shopping_cart=shopping_cart)
......
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