diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-08-22 11:05:06 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-08-22 11:05:06 +0700 |
| commit | 1297a3f4af3c847bcaf04ec7c66f052678a88e84 (patch) | |
| tree | fa0d7e8f1cf6aa54b99bc49d379dc77277d7c8fd /indoteknik_custom/models/product_template.py | |
| parent | 64e790b5d9c923c91bed9f7f9a934e9d229bca2c (diff) | |
email reminder and cr archive product
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 56460821..d51f903f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -337,7 +337,7 @@ class ProductTemplate(models.Model): raise UserError('Tidak dapat mengubah produk sementara') return super(ProductTemplate, self).write(vals) - + class ProductProduct(models.Model): _inherit = "product.product" web_price = fields.Float( @@ -367,6 +367,18 @@ class ProductProduct(models.Model): qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') short_spesification = fields.Char(string='Short Spesification') + @api.constrains('active') + def archive_product(self): + for product in self: + product_template = product.product_tmpl_id + variants = product_template.product_variant_ids + + 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 + elif not product.active and len(variants) > 1: + continue + def update_internal_reference_variants(self, limit=100): variants = self.env['product.product'].search([ ('default_code', '=', False), |
