From 857fbbf8a46c9b933bd3fb13d274fbed2f3fea39 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 Aug 2024 10:08:47 +0700 Subject: add required to public_categ_ids product template & variant --- indoteknik_custom/models/product_template.py | 12 ++++++++++++ indoteknik_custom/views/product_template.xml | 3 +++ 2 files changed, 15 insertions(+) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d51f903f..e6778758 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -61,6 +61,12 @@ class ProductTemplate(models.Model): tkdn = fields.Boolean(string='TKDN') short_spesification = fields.Char(string='Short Spesification') + @api.constrains('name', 'internal_reference', 'x_manufacture') + def required_public_categ_ids(self): + for rec in self: + if not rec.public_categ_ids: + raise UserError('Field Categories harus diisi') + def _get_qty_sold(self): for rec in self: rec.qty_sold = sum(x.qty_sold for x in rec.product_variant_ids) @@ -367,6 +373,12 @@ class ProductProduct(models.Model): qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') short_spesification = fields.Char(string='Short Spesification') + @api.constrains('name', 'internal_reference', 'x_manufacture') + def required_public_categ_ids(self): + for rec in self: + if not rec.public_categ_ids: + raise UserError('Field Categories harus diisi') + @api.constrains('active') def archive_product(self): for product in self: diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index 520af5c8..e3a39412 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -21,6 +21,9 @@ + + 1 + -- cgit v1.2.3