From ea48748650d1abe7b9c09f961eaa3762750e21be Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 6 Sep 2023 10:33:34 +0700 Subject: Add voucher terms and conditions Add voucher to sale order API --- indoteknik_custom/models/website_user_cart.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/website_user_cart.py') 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 -- cgit v1.2.3