summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_attribute.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-09-29 02:32:56 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-09-29 02:32:56 +0000
commit78f205302c35cab2512971d64c8152aab2dcfa95 (patch)
tree72be75ad949fe9efaf7b55c8f7f5722225538b28 /indoteknik_custom/models/product_attribute.py
parent50b5bd7bd984ef108e8bd324440050a222d8262f (diff)
parent0bb47005022b33c79ecfb5924d41f35ce794c5fb (diff)
Merged in production (pull request #126)
Production
Diffstat (limited to 'indoteknik_custom/models/product_attribute.py')
-rw-r--r--indoteknik_custom/models/product_attribute.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/indoteknik_custom/models/product_attribute.py b/indoteknik_custom/models/product_attribute.py
index 784ccd81..e3076805 100644
--- a/indoteknik_custom/models/product_attribute.py
+++ b/indoteknik_custom/models/product_attribute.py
@@ -5,11 +5,16 @@ import re
class ProductAttributeValue(models.Model):
_inherit = 'product.attribute.value'
+
@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, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring. Contoh: {suggest}')
+ raise UserError(f'Contoh yang benar adalah {suggest}')
+
+
+
\ No newline at end of file