diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-07-02 06:55:23 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-07-02 06:55:23 +0000 |
| commit | 42c7fe85cafd0d9100319805b6e45f1ca603ec1b (patch) | |
| tree | 2c6a826db52144535074bf29de563e2b45440528 | |
| parent | f9c5b3dffcd71bfa9dea74c946d7b4277db66bd6 (diff) | |
| parent | 8af9c48990cbd5505a5f449ea11c191a74a04072 (diff) | |
Merged in feature/add_voucher_pastihemat_productsolr (pull request #152)
Feature/add voucher pastihemat productsolr
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 920ae463..48e87b79 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -50,10 +50,18 @@ class ProductTemplate(models.Model): def _sync_product_stock_to_solr(self): self._sync_product_template_to_solr() + 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: + 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]) @@ -92,8 +100,15 @@ 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, + "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([ |
