blob: 51ef97cf305e1be63c71c137a9554bac7422b92a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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.')
|