diff options
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 5 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 1 |
3 files changed, 11 insertions, 5 deletions
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index e1342fc2..85c94741 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -5,6 +5,7 @@ from datetime import datetime class ProductProduct(models.Model): _inherit = 'product.product' + unpublished = fields.Boolean(string='Unpublished') last_update_solr = fields.Datetime(string='Last Update Solr') desc_update_solr = fields.Char(string='Desc Update Solr') @@ -63,7 +64,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': variant.active and variant.type == 'product', + 'publish_b': not variant.unpublished, 'qty_sold_f': variant.qty_sold }) @@ -170,8 +171,11 @@ class ProductProduct(models.Model): return results - @api.constrains('active') - def constrains_active(self): + @api.constrains('unpublished') + def _constrains_unpublished(self): for rec in self: + if rec.product_variant_count == 1: + rec.product_tmpl_id.unpublished = rec.unpublished + rec.product_tmpl_id._create_solr_queue_sync_product_template()
\ No newline at end of file diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index aa1708cc..25d7d4b8 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -5,6 +5,7 @@ from datetime import datetime class ProductTemplate(models.Model): _inherit = "product.template" + unpublished = fields.Boolean(string='Unpublished') last_update_solr = fields.Datetime(string='Last Update Solr') desc_update_solr = fields.Char(string='Desc Update Solr') @@ -23,7 +24,7 @@ class ProductTemplate(models.Model): 'function_name': function_name }) - @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active') + @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'unpublished') def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') @@ -80,7 +81,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.active and template.type == 'product', + 'publish_b': not template.unpublished, "qty_sold_f": template.qty_sold }) diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index a3a23101..6fdb5e8f 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -13,6 +13,7 @@ <field name="x_studio_field_tGhJR" widget="many2many_tags"/> </field> <field name="uom_po_id" position="after"> + <field name="unpublished" /> <field name="desc_update_solr" readonly="1" /> <field name="last_update_solr" readonly="1" /> </field> |
