summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/solr/product_template.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-11-24 17:07:53 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-11-24 17:07:53 +0700
commit1941896aebea3908b1763a4bd4244e5ac7e78bc6 (patch)
treee356fbd2e7d3b37d2230eb6b5b43e05f64b89fb7 /indoteknik_custom/models/solr/product_template.py
parent1a27ae4f9ec137d7af69175afb67a094873738b9 (diff)
add constrains active on template and variant
Diffstat (limited to 'indoteknik_custom/models/solr/product_template.py')
-rw-r--r--indoteknik_custom/models/solr/product_template.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 123a95ac..fd3357fd 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)])
@@ -82,7 +88,7 @@ class ProductTemplate(models.Model):
"category_name": category_name,
"description_t": template.website_description or '',
'has_product_info_b': True,
- 'publish_b': not template.unpublished or not template.active,
+ 'publish_b': not template.unpublished,
"qty_sold_f": template.qty_sold
})