summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-07-02 13:53:05 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-07-02 13:53:05 +0700
commit8af9c48990cbd5505a5f449ea11c191a74a04072 (patch)
tree2c6a826db52144535074bf29de563e2b45440528
parenta10024fec206f68791c87a5a4e56e4c6bce28f5c (diff)
add voucher_pastihemat to solr
-rw-r--r--indoteknik_custom/models/solr/product_template.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index fb4974dd..48e87b79 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -50,16 +50,18 @@ 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]}])
+ def get_voucher_pastihemat(self, brand_id):
+ voucher_line = self.env['voucher.line'].search([('voucher_id', '=', 146), ('manufacture_id', 'in', [brand_id])])
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)
+ if template.x_manufacture:
+ voucher = self.get_voucher_pastihemat(template.x_manufacture.id)
+ # Lakukan sesuatu dengan voucher
+
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])
@@ -101,10 +103,12 @@ class ProductTemplate(models.Model):
"qty_sold_f": template.qty_sold,
"voucher_pastihemat" : {
"min_purchase" : voucher.min_purchase_amount,
+ "min_purchase" : voucher.discount_type,
"discount_amount" : voucher.discount_amount,
"max_discount" : voucher.max_discount_amount
}
})
+ print(document)
self.solr().add(docs=[document], softCommit=True)
products = self.env['product.product'].search([