From 3e6c8343e93d7126f4002a23e396f22db7667774 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 15:44:31 +0700 Subject: fix archive product --- indoteknik_custom/models/product_template.py | 5 +++-- 1 file changed, 3 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) -- cgit v1.2.3 From 1a27ae4f9ec137d7af69175afb67a094873738b9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 16:51:02 +0700 Subject: add new condition on publish_b solr --- indoteknik_custom/models/solr/product_product.py | 2 +- indoteknik_custom/models/solr/product_template.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 03eaaf13..ebfa8e65 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -65,7 +65,7 @@ class ProductProduct(models.Model): 'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly, 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, - 'publish_b': not variant.unpublished, + 'publish_b': not variant.unpublished or not variant.active, 'qty_sold_f': variant.qty_sold }) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 648a0625..123a95ac 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -82,7 +82,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, + 'publish_b': not template.unpublished or not template.active, "qty_sold_f": template.qty_sold }) -- cgit v1.2.3 From 1941896aebea3908b1763a4bd4244e5ac7e78bc6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 17:07:53 +0700 Subject: add constrains active on template and variant --- indoteknik_custom/models/solr/product_product.py | 8 +++++++- indoteknik_custom/models/solr/product_template.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index ebfa8e65..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'] @@ -65,7 +71,7 @@ class ProductProduct(models.Model): 'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly, 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, - 'publish_b': not variant.unpublished or not variant.active, + 'publish_b': not variant.unpublished, 'qty_sold_f': variant.qty_sold }) 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 }) -- cgit v1.2.3