summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHATEC\SPVDEV001 <tri.susilo@altama.co.id>2024-06-18 15:55:21 +0700
committerHATEC\SPVDEV001 <tri.susilo@altama.co.id>2024-06-18 15:55:21 +0700
commit51c19eca13239fe20ae592f8e9ee0d23f8904c5f (patch)
tree1c5b994aabb3dd3cf760676ee6af4e40b2a1fa77
parent6b1745b06fef67a3310b176e71d73d840935398a (diff)
add voucher
-rw-r--r--indoteknik_custom/models/solr/product_template.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 920ae463..fb4974dd 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -50,10 +50,16 @@ class ProductTemplate(models.Model):
def _sync_product_stock_to_solr(self):
self._sync_product_template_to_solr()
+ def get_voucher_pastihemat(self, brandId):
+ voucher_line = self.env['voucher.line'].search([{'voucher_id.code', '=', 'PASTIHEMAT'}, {'manufacure_id', 'in' ,[brandId]}])
+ return voucher_line
+
def _sync_product_template_to_solr(self):
solr_model = self.env['apache.solr']
for template in self:
+
+ voucher = self.get_voucher_pastihemat(template.x_manufacture.id)
variant_names = ', '.join([x.display_name or '' for x in template.product_variant_ids])
variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids])
@@ -92,7 +98,12 @@ class ProductTemplate(models.Model):
'publish_b': not template.unpublished,
'sni_b': template.unpublished,
'tkdn_b': template.unpublished,
- "qty_sold_f": template.qty_sold
+ "qty_sold_f": template.qty_sold,
+ "voucher_pastihemat" : {
+ "min_purchase" : voucher.min_purchase_amount,
+ "discount_amount" : voucher.discount_amount,
+ "max_discount" : voucher.max_discount_amount
+ }
})
self.solr().add(docs=[document], softCommit=True)