summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-09-20 09:42:33 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-09-20 09:42:33 +0700
commit6481b0748f6872a37961252a213e55cec8227ed5 (patch)
tree53ab50337615fea4f7ae44a9f7f6d55f91711ed2 /indoteknik_custom/models/product_template.py
parent5383121fbdc4e2f899e6bbe7e0402402a8f8eaf4 (diff)
fix product attribute name
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index cf3df153..2ce2c185 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -104,11 +104,12 @@ class ProductTemplate(models.Model):
@api.constrains('name')
def _validate_name(self):
- pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/%-]+$'
+ rule_regex = self.env['ir.config_parameter'].sudo().get_param('product.product.rule_name_regex') or ''
+ pattern = rf'^{rule_regex}$'
if not re.match(pattern, self.name):
- pattern_suggest = r'[a-zA-Z0-9\[\]\(\)\.\s/%-]+'
+ pattern_suggest = rf"{rule_regex}"
suggest = ''.join(re.findall(pattern_suggest, self.name))
- raise UserError(f'Nama hanya bisa menggunakan angka, strip, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring. Contoh: {suggest}')
+ raise UserError(f'Contoh yang benar adalah {suggest}')
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
@@ -374,11 +375,12 @@ class ProductProduct(models.Model):
@api.constrains('name')
def _validate_name(self):
- pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/%-]+$'
+ rule_regex = self.env['ir.config_parameter'].sudo().get_param('product.product.rule_name_regex') or ''
+ pattern = rf'^{rule_regex}$'
if not re.match(pattern, self.name):
- pattern_suggest = r'[a-zA-Z0-9\[\]\(\)\.\s/%-]+'
+ pattern_suggest = rf"{rule_regex}"
suggest = ''.join(re.findall(pattern_suggest, self.name))
- raise UserError(f'Nama hanya bisa menggunakan angka, strip, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring. Contoh: {suggest}')
+ raise UserError(f'Contoh yang benar adalah {suggest}')
def _get_qty_incoming_bandengan(self):
for product in self: