diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-04-12 15:33:33 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-04-12 15:33:33 +0700 |
| commit | fe8f1c997224aa2c6cdd01e14562668d7cbffaf5 (patch) | |
| tree | 11ebb7c50536608ce821828d110643e1814b68d1 /indoteknik_api/models | |
| parent | 9fd01a2999a88973b583a86f52f120a41571d7d7 (diff) | |
prepare for tiering price api solr
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/product_product.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 39cc9b28..32bd7c21 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -133,6 +133,60 @@ class ProductProduct(models.Model): res = price_after_disc * default_percent_tax / 100 return math.floor(res) + def _get_pricelist_tier1(self): + default_divide_tax = float(1.11) + base_price = discount = price = 0 + pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 15037), ('product_id', '=', self.id)], limit=1) + if pricelist_item: + # base_price = self._get_website_price_exclude_tax() + base_price_incl = self._get_website_price_include_tax() + discount = pricelist_item.price_discount + price = base_price_incl - (base_price_incl * discount / 100) + price = price / default_divide_tax + price = math.floor(price) + data = { + # 'base_price_tier1': base_price or 0, + 'discount_tier1': discount or 0, + 'price_tier1': price or 0 + } + return data + + def _get_pricelist_tier2(self): + default_divide_tax = float(1.11) + base_price = discount = price = 0 + pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 15038), ('product_id', '=', self.id)], limit=1) + if pricelist_item: + # base_price = self._get_website_price_exclude_tax() + base_price_incl = self._get_website_price_include_tax() + discount = pricelist_item.price_discount + price = base_price_incl - (base_price_incl * discount / 100) + price = price / default_divide_tax + price = math.floor(price) + data = { + # 'base_price_tier2': base_price or 0, + 'discount_tier2': discount or 0, + 'price_tier2': price or 0 + } + return data + + def _get_pricelist_tier3(self): + default_divide_tax = float(1.11) + base_price = discount = price = 0 + pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 15039), ('product_id', '=', self.id)], limit=1) + if pricelist_item: + # base_price = self._get_website_price_exclude_tax() + base_price_incl = self._get_website_price_include_tax() + discount = pricelist_item.price_discount + price = base_price_incl - (base_price_incl * discount / 100) + price = price / default_divide_tax + price = math.floor(price) + data = { + # 'base_price_tier3': base_price or 0, + 'discount_tier3': discount or 0, + 'price_tier3': price or 0 + } + return data + def _get_flashsale_price(self): # must get active pricelist active_flash_sale = self.env['product.pricelist'].get_active_flash_sale() |
