summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-24 09:03:52 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-24 09:03:52 +0700
commitcc4be72fc2f0d98f8bc2190ea5c404536bb3c56d (patch)
treea00f22741ba1ec63b59659834a9c6177b20db343 /indoteknik_custom/models/product_template.py
parent1f9d0136758531831ea6c7a90556c9a472ed8d40 (diff)
parent649f3037e4357dab42d1a8d799e5f2a2f1fd2e52 (diff)
Merge branch 'production' into unreserved_permission
# Conflicts: # indoteknik_custom/models/sale_order.py
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py10
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([