summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-03-30 10:28:08 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-03-30 10:28:08 +0700
commit534dd15d461f7e1aa83f31f24dcd953f69c2c113 (patch)
tree9b841dfe488fd6d2f9434ddc24736c54ca227923
parentc165e5bffe4c6649399e6bf3852ebb4fafde0dc9 (diff)
add discount in solr
-rw-r--r--indoteknik_custom/models/apache_solr.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/indoteknik_custom/models/apache_solr.py b/indoteknik_custom/models/apache_solr.py
index 105a26be..abdb1d50 100644
--- a/indoteknik_custom/models/apache_solr.py
+++ b/indoteknik_custom/models/apache_solr.py
@@ -25,21 +25,32 @@ class ApacheSolr(models.Model):
counter = 0
for template in templates:
counter += 1
- price_excl_after_disc = price_excl = 0
+ price_excl_after_disc = price_excl = discount = tax = 0
variants_name = variants_code = ''
if template.product_variant_count > 1:
for variant in template.product_variant_ids:
if price_excl_after_disc == 0:
price_excl = variant._get_website_price_exclude_tax()
price_excl_after_disc = variant._get_website_price_after_disc_and_tax()
+ discount = variant._get_website_disc()
+ tax = variant._get_website_tax()
elif variant._get_website_price_after_disc_and_tax() < price_excl_after_disc:
price_excl_after_disc = variant._get_website_price_after_disc_and_tax()
price_excl = variant._get_website_price_exclude_tax()
+ discount = variant._get_website_disc()
+ tax = variant._get_website_tax()
else:
price_excl_after_disc = price_excl_after_disc
price_excl = price_excl
+ discount = discount
+ tax = tax
variants_name += variant.display_name or ''+', '
variants_code += variant.default_code or ''+', '
+ else:
+ price_excl = template.product_variant_id._get_website_price_exclude_tax()
+ discount = template.product_variant_id._get_website_price_after_disc_and_tax()
+ price_excl_after_disc = template.product_variant_id._get_website_price_after_disc_and_tax()
+ tax = template.product_variant_id._get_website_tax()
document=[({
'id': template.id,
@@ -49,9 +60,10 @@ class ApacheSolr(models.Model):
'product_rating_f': template.product_rating,
'product_id_i': template.id,
'image_s': self.env['ir.attachment'].api_image('product.template', 'image_512', template.id),
- 'price_f': price_excl or template.product_variant_id._get_website_price_exclude_tax(),
- 'price_discount_f': price_excl_after_disc or template.product_variant_id._get_website_price_after_disc_and_tax(),
- 'tax_f': template.product_variant_id._get_website_tax(),
+ 'price_f': price_excl,
+ 'discount_f': discount,
+ 'price_discount_f': price_excl_after_disc,
+ 'tax_f': tax,
'variant_total_i': template.product_variant_count,
'stock_total_f': template.qty_stock_vendor,
'weight_f': template.weight,