summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-11-25 09:21:47 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-11-25 09:21:47 +0700
commit693e78afa8b9b4df99f417392b42bff12ea41f9e (patch)
treeb63d7afc1dfbb917f62575af5fb2ed7347d3cc59
parente9dec832ab749b1c72dc358603d00ad7a35d4bb6 (diff)
parent1941896aebea3908b1763a4bd4244e5ac7e78bc6 (diff)
Merge branch 'production' of https://bitbucket.org/altafixco/indoteknik-addons into production
-rwxr-xr-xindoteknik_custom/models/product_template.py5
-rw-r--r--indoteknik_custom/models/solr/product_product.py6
-rw-r--r--indoteknik_custom/models/solr/product_template.py6
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)])