diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-23 15:05:00 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-23 15:05:00 +0700 |
| commit | 5ff183f7ee77c99327d90e178bdccf77ab2c2cc4 (patch) | |
| tree | dabca3543c725ac0fc5d66e734c57f2b75fd6d50 /indoteknik_custom/models/product_attribute.py | |
| parent | 1e172ec6265592dbd92789c216983ffee5f40e9f (diff) | |
add new validation for product and product attribute
Diffstat (limited to 'indoteknik_custom/models/product_attribute.py')
| -rw-r--r-- | indoteknik_custom/models/product_attribute.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_attribute.py b/indoteknik_custom/models/product_attribute.py new file mode 100644 index 00000000..51ef97cf --- /dev/null +++ b/indoteknik_custom/models/product_attribute.py @@ -0,0 +1,13 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError +import re + +class ProductAttributeValue(models.Model): + _inherit = 'product.attribute.value' + + @api.constrains('name') + def _validate_name(self): + pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/]+$' + if not re.match(pattern, self.name): + raise UserError('Nama hanya bisa menggunakan angka, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring.') +
\ No newline at end of file |
