diff options
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 12 |
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([ |
