From 69a632f84aff35bf7f57005190dee07f9a6d7040 Mon Sep 17 00:00:00 2001 From: IT Fixcomart Date: Fri, 7 Oct 2022 08:52:24 +0700 Subject: FIx bug api flash sale --- indoteknik_api/models/product_pricelist.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/indoteknik_api/models/product_pricelist.py b/indoteknik_api/models/product_pricelist.py index 3a807f3a..f40efd5d 100644 --- a/indoteknik_api/models/product_pricelist.py +++ b/indoteknik_api/models/product_pricelist.py @@ -35,20 +35,21 @@ class ProductPricelist(models.Model): is_compute_formula = False else: is_compute_formula = False - - product = self.env['product.product'].browse(product_id) - if product: - for tax in product.taxes_id: - if not tax.price_include: - price *= (100 + tax.amount) / 100 - + price_discount = price - for discount in discounts: - price_discount *= (100 - discount) / 100 - discount_percentage = 0 - if len(discounts) > 0: - discount_percentage = (price - price_discount) / price * 100 + if price > 0: + product = self.env['product.product'].browse(product_id) + if product: + for tax in product.taxes_id: + if not tax.price_include: + price *= (100 + tax.amount) / 100 + + for discount in discounts: + price_discount *= (100 - discount) / 100 + + if len(discounts) > 0: + discount_percentage = (price - price_discount) / price * 100 return { 'price': price, -- cgit v1.2.3