summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-13 16:51:28 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-13 16:51:28 +0700
commit2e9f95e8201692317d1ce23f6992fdb0e37dc95c (patch)
treea0a33a2daa9e7dc478dc3bb34892e9f3ae21e4bd
parent649a8f0d51b8fa7dc90dfbd0967e94dd586cd0aa (diff)
cr archive product
-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([