diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-12 15:43:52 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-12 15:43:52 +0700 |
| commit | 890be59e4dadafc6e25651fcb9de20e2b24379cc (patch) | |
| tree | a699e771693a3f89633f01d1870aee11d0cb76c1 | |
| parent | 888a3ca6337a1622f4f16b98b700cdd437ab6023 (diff) | |
Sync to solr product variant solr flag 2, Sync to solr product template solr flag 2
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 9 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/views/product_product.xml | 16 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 15 |
4 files changed, 46 insertions, 1 deletions
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 @@ <field name="state">code</field> <field name="code">model.action_sync_to_solr()</field> </record> + + <data noupdate="1"> + <record id="cron_variant_solr_flag_solr" model="ir.cron"> + <field name="name">Sync Variant To Solr: Solr Flag 2</field> + <field name="interval_number">10</field> + <field name="interval_type">minutes</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + <field name="model_id" ref="model_product_product"/> + <field name="code">model.variant_solr_flag_to_solr()</field> + <field name="state">code</field> + <field name="priority">55</field> + <field name="active">True</field> + </record> + </data> + </data> </odoo>
\ 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 @@ <field name="state">code</field> <field name="code">model.action_sync_to_solr()</field> </record> + + <data noupdate="1"> + <record id="cron_product_solr_flag_solr" model="ir.cron"> + <field name="name">Sync Product To Solr: Solr Flag 2</field> + <field name="interval_number">10</field> + <field name="interval_type">minutes</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + <field name="model_id" ref="model_product_template"/> + <field name="code" eval="('model.solr_flag_to_solr', ())"/> + <field name="state">code</field> + <field name="priority">55</field> + <field name="active">True</field> + </record> + </data> </data> </odoo>
\ No newline at end of file |
