diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-11-17 17:20:23 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-11-17 17:20:23 +0700 |
| commit | 96af7230bdd79234fadeca8110b65dafa5b70a53 (patch) | |
| tree | f3f37c555fe939852db2659f52e344e48acc1202 /indoteknik_api/models | |
| parent | fa27a62a2ecc046020e57849838b633d78a99c36 (diff) | |
| parent | f168734f000ea34fc3a15bdf4b6af9f4fe797d06 (diff) | |
Merge branch 'master' of git@bitbucket.org:altafixco/indoteknik-addons.git
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/product_pricelist.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/indoteknik_api/models/product_pricelist.py b/indoteknik_api/models/product_pricelist.py index 6a011934..4e5c9501 100644 --- a/indoteknik_api/models/product_pricelist.py +++ b/indoteknik_api/models/product_pricelist.py @@ -5,21 +5,10 @@ from datetime import datetime class ProductPricelist(models.Model): _inherit = 'product.pricelist' - - def compute_price(self, pricelist_id: int, product_id: int): - """ - Compute price with tax, discount formula, and fixed_price - @param pricelist_id: id of product.pricelist - @param product_id: id of product.product - @return: returns price value from pricelist. - """ + + def get_product_price(self, pricelist_id: int, product_id: int): price = 0 discounts = [] - - is_flash_sale_product = self.is_flash_sale_product(product_id) - if is_flash_sale_product: - pricelist_id = is_flash_sale_product - is_compute_formula = True while is_compute_formula: pricelist = self.env['product.pricelist.item'].search([ @@ -35,7 +24,24 @@ class ProductPricelist(models.Model): is_compute_formula = False else: is_compute_formula = False - + return price, discounts + + def compute_price(self, pricelist_id: int, product_id: int): + """ + Compute price with tax, discount formula, and fixed_price + @param pricelist_id: id of product.pricelist + @param product_id: id of product.product + @return: returns price value from pricelist. + """ + is_flash_sale_product = self.is_flash_sale_product(product_id) + if is_flash_sale_product: + pricelist_id = is_flash_sale_product + + price, discounts = self.get_product_price(pricelist_id, product_id) + if price == 0: + product_pricelist_default_price_id = self.env['ir.config_parameter'].get_param('product.pricelist.default_price_id') + price, discounts = self.get_product_price(int(product_pricelist_default_price_id), product_id) + price_discount = price discount_percentage = 0 if price > 0: |
