diff options
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 5 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 6 |
3 files changed, 15 insertions, 2 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 264d0bbb..90e8a144 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -315,8 +315,9 @@ class ProductTemplate(models.Model): return values def write(self, vals): - if self.id == 224484: - raise UserError('Tidak dapat mengubah produk sementara') + for rec in self: + if rec.id == 224484: + raise UserError('Tidak dapat mengubah produk sementara') return super(ProductTemplate, self).write(vals) 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 c09a6e5a..bba98edc 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -28,6 +28,12 @@ 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)]) |
