diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-02 09:44:39 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-02 09:44:39 +0700 |
| commit | 2739d3040a69228192096ee16373610149a2fb47 (patch) | |
| tree | 545aa797d7407e8f22250dff15648495b891928f /indoteknik_custom/models/product_template.py | |
| parent | 4d3d219b5f1002822a16067a28261fd59b170ff8 (diff) | |
| parent | 7d3780ede67579b5891218efc370dc82eef510a1 (diff) | |
Merge branch 'production' of https://bitbucket.org/altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index e6778758..031d1b5b 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -338,9 +338,9 @@ class ProductTemplate(models.Model): return values def write(self, vals): - for rec in self: - if rec.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) @@ -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([ |
