Browse Source

moving email regex to module data and adding unique constraint

pull/246/head
eLBati 9 years ago
parent
commit
fccb35cc6e
  1. 3
      base_field_validator/__openerp__.py
  2. 0
      base_field_validator/data/ir_model_regex_data.xml
  3. 12
      base_field_validator/demo/ir_model_regex_demo.yml
  4. 4
      base_field_validator/models/ir_model_field_regex.py
  5. 12
      base_field_validator/test/validator.yml

3
base_field_validator/__openerp__.py

@ -14,9 +14,10 @@
"data": [
'views/ir_model_view.xml',
'security/ir.model.access.csv',
'data/ir_model_regex_data.xml',
],
"demo": [
'demo/ir_model_demo.xml',
'demo/ir_model_regex_demo.yml',
],
'test': [
'test/validator.yml',

0
base_field_validator/demo/ir_model_demo.xml → base_field_validator/data/ir_model_regex_data.xml

12
base_field_validator/demo/ir_model_regex_demo.yml

@ -0,0 +1,12 @@
-
set regex for partner
-
!python {model: ir.model}: |
self.write(cr, uid, [ref('base.model_res_partner')], {
'validator_line_ids': [(0,0,
{
'model_id': ref('base.model_res_partner'),
'field_id': ref('base.field_res_partner_email'),
'regex_id': ref('regex_mail'),
})],
})

4
base_field_validator/models/ir_model_field_regex.py

@ -13,3 +13,7 @@ class IrModelFieldsRegex(models.Model):
help="Regular expression used to validate the field. For example, "
"you can add the expression\n%s\nto the email field"
% r'[^@]+@[^@]+\.[^@]+')
_sql_constraints = [(
'name_unique', 'unique (name)',
'The name of a regular expression must be unique'
)]

12
base_field_validator/test/validator.yml

@ -1,15 +1,3 @@
-
set regex for partner
-
!python {model: ir.model}: |
self.write(cr, uid, [ref('base.model_res_partner')], {
'validator_line_ids': [(0,0,
{
'model_id': ref('base.model_res_partner'),
'field_id': ref('base.field_res_partner_email'),
'regex_id': ref('regex_mail'),
})],
})
-
Set valid email
-

Loading…
Cancel
Save