summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/product_attribute.py6
-rwxr-xr-xindoteknik_custom/models/product_template.py13
2 files changed, 12 insertions, 7 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
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index a69d6942..52f72729 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -54,10 +54,11 @@ class ProductTemplate(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}')
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
@@ -289,9 +290,11 @@ class ProductProduct(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}')
def _get_qty_incoming_bandengan(self):
for product in self: