diff options
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 000ee3bf..031d1b5b 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -388,8 +388,16 @@ class ProductProduct(models.Model): if product_template.active and product.active: if not product.active and len(variants) == 1: product_template.with_context(skip_active_constraint=True).active = False + product_template.unpublished = True elif not product.active and len(variants) > 1: - continue + all_inactive = all(not variant.active for variant in variants) + if all_inactive: + product_template.with_context(skip_active_constraint=True).active = False + product_template.unpublished = True + else: + continue + if any(variant.active for variant in variants): + product_template.unpublished = False def update_internal_reference_variants(self, limit=100): variants = self.env['product.product'].search([ |
