From eff76a5d9671ba8a39b58166e3df9428a1f10e0c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Aug 2023 14:14:43 +0700 Subject: move code to folder solr --- indoteknik_custom/models/solr/product_pricelist_item.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/solr') diff --git a/indoteknik_custom/models/solr/product_pricelist_item.py b/indoteknik_custom/models/solr/product_pricelist_item.py index fa042480..3be8c4c0 100644 --- a/indoteknik_custom/models/solr/product_pricelist_item.py +++ b/indoteknik_custom/models/solr/product_pricelist_item.py @@ -7,4 +7,14 @@ class ProductPricelistItem(models.Model): @api.constrains('applied_on', 'product_id', 'base', 'base_pricelist_id', 'price_discount') def _constrains_related_solr_field(self): for rec in self: - rec.product_id.product_tmpl_id._create_solr_queue('_sync_price_to_solr') \ No newline at end of file + rec.product_id.product_tmpl_id._create_solr_queue('_sync_price_to_solr') + + def action_sync_to_solr(self): + active_ids = self.env.context.get('active_ids', []) + + for pricelist_item_id in active_ids: + pricelist = self.env['product.pricelist.item'].browse(pricelist_item_id) + + templates = self.env['product.template'].search([('id', 'in', [pricelist.product_id.product_tmpl_id.id])]) + + templates._create_solr_queue('_sync_price_to_solr') -- cgit v1.2.3