|
@ -36,16 +36,16 @@ class IrModel(models.Model): |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|
def check_vals(self, vals, model_name): |
|
|
def check_vals(self, vals, model_name): |
|
|
models = self.search([('model', '=', model_name)]) |
|
|
|
|
|
for model in models: |
|
|
|
|
|
for validator_line in model.validator_line_ids: |
|
|
|
|
|
if validator_line.field_id.name in vals: |
|
|
|
|
|
pattern = re.compile(validator_line.regex_id.regex) |
|
|
|
|
|
if not pattern.match(vals[validator_line.field_id.name]): |
|
|
|
|
|
raise Warning( |
|
|
|
|
|
_('Expression %s not valid for %s') % ( |
|
|
|
|
|
validator_line.regex_id.regex, |
|
|
|
|
|
vals[validator_line.field_id.name])) |
|
|
|
|
|
|
|
|
models = self.search([('model', '=', model_name)], limit=1) |
|
|
|
|
|
model = models[0] |
|
|
|
|
|
for validator_line in model.validator_line_ids: |
|
|
|
|
|
if validator_line.field_id.name in vals: |
|
|
|
|
|
pattern = re.compile(validator_line.regex_id.regex) |
|
|
|
|
|
if not pattern.match(vals[validator_line.field_id.name]): |
|
|
|
|
|
raise Warning( |
|
|
|
|
|
_('Expression %s not valid for %s') % ( |
|
|
|
|
|
validator_line.regex_id.regex, |
|
|
|
|
|
vals[validator_line.field_id.name])) |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|