diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-06 11:17:53 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-10-06 11:17:53 +0700 |
| commit | 2fa15330d221cb68e5b9acdb4379aa82764f46f0 (patch) | |
| tree | 0139db5bc9605080a38e23ed8733cf423b4b9657 /indoteknik_api/models | |
| parent | 12b015dc599f3a3876b10171bcec95e8aba7683c (diff) | |
Update flashsale calculation price for web and odoo
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/product_product.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index bcba8cfc..d370e52b 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -251,6 +251,7 @@ class ProductProduct(models.Model): return data def _get_flashsale_price(self): + price_for = self.env.context.get('price_for', 'odoo') result = {} current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') @@ -264,7 +265,16 @@ class ProductProduct(models.Model): if not item: return result - base_price = self._v2_get_website_price_exclude_tax() + tier1_id = self.env['ir.config_parameter'].get_param('product.pricelist.tier1_v2', 0) + base_pricelist = self.env['product.pricelist.item'].search([ + ('pricelist_id', '=', int(tier1_id)), + ('product_id', '=', self.id) + ], limit=1) + + base_price = 0 + if base_pricelist: + base_price = base_pricelist.computed_price + discount = 0 price_flashsale = 0 if item.price_discount > 0: @@ -274,6 +284,10 @@ class ProductProduct(models.Model): price_flashsale = item.fixed_price # ask darren for include or exclude discount = (base_price - price_flashsale) // base_price * 100 + if price_for == 'odoo': + base_price = self._v2_get_website_price_include_tax() + discount = (base_price - price_flashsale) / base_price * 100 + jkt_tz = pytz.timezone('Asia/Jakarta') result.update({ 'flashsale_id': item.pricelist_id.id, |
