Browse Source

Improve validator_line check

pull/246/head
eLBati 9 years ago
parent
commit
83805f3b42
  1. 8
      base_field_validator/models/ir_model.py

8
base_field_validator/models/ir_model.py

@ -23,10 +23,10 @@ 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)], limit=1)
model = models[0]
for validator_line in model.validator_line_ids:
if validator_line.field_id.name in vals:
validator_lines = self.env['ir.model.validator.line'].search([
('name.model', '=', model_name),
('field_id.name', 'in', vals.keys())])
for validator_line in validator_lines:
pattern = re.compile(validator_line.regex_id.regex) pattern = re.compile(validator_line.regex_id.regex)
if vals[validator_line.field_id.name]: if vals[validator_line.field_id.name]:
if not pattern.match(vals[validator_line.field_id.name]): if not pattern.match(vals[validator_line.field_id.name]):

Loading…
Cancel
Save