Browse Source

Merge pull request #36 from rdcprojects/10.0

[UPDT] Percentage discount calculation fixed
pull/30/merge
Cybrosys Technologies 8 years ago
committed by GitHub
parent
commit
6c0d21be25
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      website_coupon/controllers/main.py

15
website_coupon/controllers/main.py

@ -113,8 +113,19 @@ class WebsiteCoupon(http.Controller):
return request.redirect("/shop/cart?coupon_not_available=3")
elif type == 'percentage':
# coupon type is percentage -------------------------------------
amount_final = (voucher_val/100) * order.amount_total
res = coupon_product.product_tmpl_id.write({'list_price': -amount_final})
if voucher_type == 'product':
for line in order.order_line:
if line.product_id.name == categ_id.name:
amount_final = (voucher_val / 100) * line.price_total
break
elif voucher_type == 'category':
amount_final = 0
for line in order.order_line:
if line.product_id.categ_id.name == product_id.name:
amount_final += (voucher_val / 100) * line.price_total
elif voucher_type == 'all':
amount_final = (voucher_val/100) * order.amount_total
res = coupon_product.product_tmpl_id.write({'list_price': -amount_final})
value = order._cart_update(product_id=coupon_product.id, set_qty=1, add_qty=1)
# updating coupon balance--------------

Loading…
Cancel
Save