diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-08-27 10:08:47 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-08-27 10:08:47 +0700 |
| commit | 857fbbf8a46c9b933bd3fb13d274fbed2f3fea39 (patch) | |
| tree | 53427322ed01b1d25b24d35369b9e0ad345df500 | |
| parent | 322aadd72ecb5a55c41397ecd32809f18373d53b (diff) | |
add required to public_categ_ids product template & variant
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 3 |
2 files changed, 15 insertions, 0 deletions
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 @@ <field name="desc_update_solr" readonly="1" /> <field name="last_update_solr" readonly="1" /> </field> + <field name="public_categ_ids" position="attributes"> + <attribute name="required">1</attribute> + </field> <page name="inventory" position="after"> <page string="Marketplace" name="marketplace"> <group> |
