diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-06 10:33:34 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-06 10:33:34 +0700 |
| commit | ea48748650d1abe7b9c09f961eaa3762750e21be (patch) | |
| tree | 6fabd4d2aff8d88fb76aa3fb4a10478975bd3c47 /indoteknik_custom/models/website_user_cart.py | |
| parent | a8404a3ed4423dd7d86f8637ecbf35b7cc18a14c (diff) | |
Add voucher terms and conditions
Add voucher to sale order API
Diffstat (limited to 'indoteknik_custom/models/website_user_cart.py')
| -rw-r--r-- | indoteknik_custom/models/website_user_cart.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index bf7016f8..b3695ba1 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -71,7 +71,17 @@ class WebsiteUserCart(models.Model): subtotal = total_purchase - total_discount discount_voucher = 0 if voucher: - discount_voucher = voucher.calculate_discount(subtotal) + order_line = [] + for product in products: + order_line.append({ + 'product_id': self.env['product.product'].browse(product['id']), + 'price': product['price']['price'], + 'discount': product['price']['discount_percentage'], + 'qty': product['quantity'], + 'subtotal': product['subtotal'] + }) + voucher_info = voucher.apply(order_line) + discount_voucher = voucher_info['discount']['all'] subtotal -= discount_voucher tax = round(subtotal * 0.11) grand_total = subtotal + tax |
