summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_attribute.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-08-23 15:16:46 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-08-23 15:16:46 +0700
commitc8398db512ed8e5dd2ca865d72ac2a1b084c11dc (patch)
tree63107ca03a6edbb71bcd2222b01dd7493c33b8f4 /indoteknik_custom/models/product_attribute.py
parentd5570794052940761a9550f5f709d8e75dafd379 (diff)
add validation
Diffstat (limited to 'indoteknik_custom/models/product_attribute.py')
-rw-r--r--indoteknik_custom/models/product_attribute.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/indoteknik_custom/models/product_attribute.py b/indoteknik_custom/models/product_attribute.py
index 51ef97cf..784ccd81 100644
--- a/indoteknik_custom/models/product_attribute.py
+++ b/indoteknik_custom/models/product_attribute.py
@@ -7,7 +7,9 @@ class ProductAttributeValue(models.Model):
@api.constrains('name')
def _validate_name(self):
- pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/]+$'
+ 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.')
+ pattern_suggest = r'[a-zA-Z0-9\[\]\(\)\.\s/%]+'
+ suggest = ''.join(re.findall(pattern_suggest, self.name))
+ raise UserError(f'Nama hanya bisa menggunakan angka, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring. Contoh: {suggest}')
\ No newline at end of file