summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-09-23 12:35:22 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-09-23 12:35:22 +0700
commita74adc5dc9bfbbd87c308aa040b605e4160e0d17 (patch)
tree22712130c098997acabdc932aa7bad875c2347ca
parenteb765ba62294f05434bb8741050919dab11f165a (diff)
fix bug pricelist
-rw-r--r--indoteknik_api/models/product_product.py20
-rwxr-xr-xindoteknik_custom/models/product_template.py8
2 files changed, 8 insertions, 20 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index 71022af5..78e32762 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -64,9 +64,9 @@ class ProductProduct(models.Model):
price_discount = self._get_website_price_after_disc_and_tax()
pricelists = {
- 'tier1': self._get_pricelist_tier1,
- 'tier2': self._get_pricelist_tier2,
- 'tier3': self._get_pricelist_tier3,
+ 'tier1': self._get_pricelist_tier(1),
+ 'tier2': self._get_pricelist_tier(2),
+ 'tier3': self._get_pricelist_tier(3),
}
price_tier = pricelist.get_tier_name()
@@ -220,12 +220,15 @@ class ProductProduct(models.Model):
default_divide_tax = float(1.11)
base_price = discount = price = 0
pricelist_item = self.env['product.pricelist.item'].search([
- ('pricelist_id', '=', product_pricelist_tier),
+ ('pricelist_id', '=', int(product_pricelist_tier)),
('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()
+ if tier_number in ['1_v2', '2_v2', '3_v2', '4_v2', '5_v2']:
+ base_price_incl = self._v2_get_website_price_include_tax()
+
discount = pricelist_item.price_discount
price = base_price_incl - (base_price_incl * discount / 100)
price = price / default_divide_tax
@@ -235,15 +238,6 @@ class ProductProduct(models.Model):
f'price_tier{tier_number}': price or 0
}
return data
-
- def _get_pricelist_tier1(self):
- return self._get_pricelist_tier(1)
-
- def _get_pricelist_tier2(self):
- return self._get_pricelist_tier(2)
-
- def _get_pricelist_tier3(self):
- return self._get_pricelist_tier(3)
def _get_flashsale_price(self):
result = {}
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index ed722d5e..d35188b4 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -193,13 +193,7 @@ class ProductTemplate(models.Model):
def _compute_web_price(self):
for template in self:
- # product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
-
- product_pricelist_item = self.env['product.pricelist.item'].search([
- ('pricelist_id', '=', 1),
- ('product_id', '=', template.product_variant_id.id)], limit=1)
- price = product_pricelist_item.fixed_price
- template.web_price = price
+ template.web_price = template.product_variant_ids[0].web_price
def _have_promotion_program(self):
for template in self: