From 890be59e4dadafc6e25651fcb9de20e2b24379cc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Sep 2023 15:43:52 +0700 Subject: Sync to solr product variant solr flag 2, Sync to solr product template solr flag 2 --- indoteknik_custom/models/solr/product_product.py | 9 ++++++++- indoteknik_custom/models/solr/product_template.py | 7 +++++++ indoteknik_custom/views/product_product.xml | 16 ++++++++++++++++ indoteknik_custom/views/product_template.xml | 15 +++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index a3bd3d04..23ab51fd 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -20,6 +20,13 @@ class ProductProduct(models.Model): products = self.search([('id', 'in', product_ids)]) for product in products: product.product_tmpl_id._create_solr_queue('_sync_product_template_to_solr') + + def variant_solr_flag_to_solr(self, limit=500): + variant_products = self.search([('solr_flag', '=', 2)], limit=limit) + if variant_products: + for product in variant_products: + product._create_solr_queue('_sync_price_to_solr') + product.solr_flag = 1 def _sync_variants_to_solr(self): solr_model = self.env['apache.solr'] @@ -62,7 +69,7 @@ class ProductProduct(models.Model): variant.change_solr_data('Perubahan pada data product') self.solr().commit() - + def _sync_price_to_solr(self): solr_model = self.env['apache.solr'] diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index b93d0a4f..9d714713 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -35,6 +35,13 @@ class ProductTemplate(models.Model): template_ids = self.env.context.get('active_ids', []) templates = self.search([('id', 'in', template_ids)]) templates._create_solr_queue('_sync_product_template_to_solr') + + def solr_flag_to_solr(self, limit=500): + template_products = self.search([('solr_flag', '=', 2)], limit=limit) + if template_products: + for product in template_products: + product._create_solr_queue('_sync_price_to_solr') + product.solr_flag = 1 def _sync_active_template_solr(self): for template in self: diff --git a/indoteknik_custom/views/product_product.xml b/indoteknik_custom/views/product_product.xml index 6d547712..9dd1f0a4 100644 --- a/indoteknik_custom/views/product_product.xml +++ b/indoteknik_custom/views/product_product.xml @@ -20,5 +20,21 @@ code model.action_sync_to_solr() + + + + Sync Variant To Solr: Solr Flag 2 + 10 + minutes + -1 + + + model.variant_solr_flag_to_solr() + code + 55 + True + + + \ No newline at end of file diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index b2939867..f4e74199 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -84,5 +84,20 @@ code model.action_sync_to_solr() + + + + Sync Product To Solr: Solr Flag 2 + 10 + minutes + -1 + + + + code + 55 + True + + \ No newline at end of file -- cgit v1.2.3