diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-11-25 02:42:37 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-11-25 02:42:37 +0000 |
| commit | 4dcd1e3e1a3e4dced5a2d0d89d2fd4ee3e1fe7d3 (patch) | |
| tree | 3e15c66065c81eead3fb40c9f87e3f2c269e20f2 /indoteknik_custom/models/solr | |
| parent | 2aee5a44abbe36961dfe23cc3d656aa48e11e0f9 (diff) | |
| parent | 693e78afa8b9b4df99f417392b42bff12ea41f9e (diff) | |
Merged in production (pull request #132)
Production
Diffstat (limited to 'indoteknik_custom/models/solr')
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 03eaaf13..fe2a08dc 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -29,6 +29,12 @@ class ProductProduct(models.Model): product.product_tmpl_id._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 + @api.constrains('active') + def _constrains_active(self): + for rec in self: + if not rec.active: + rec.unpublished = True + def _sync_variants_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 648a0625..bba98edc 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -28,13 +28,19 @@ class ProductTemplate(models.Model): def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') + @api.constrains('active') + def _constrains_active(self): + for rec in self: + if not rec.active: + rec.unpublished = True + def action_sync_to_solr(self): 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) + template_products = self.search([('solr_flag', '=', 2), ('active', 'in', [True, False])], limit=limit) for product in template_products: product._create_solr_queue('_sync_product_template_to_solr') product._create_solr_queue('_sync_price_to_solr') |
