Merge lp:~openerp-dev/openobject-server/6.0-opw-fields_name_constraint_-ach into lp:openobject-server/6.0

Proposed by Anup(SerpentCS)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-fields_name_constraint_-ach
Merge into: lp:openobject-server/6.0
Diff against target: 24 lines (+14/-0)
1 file modified
bin/addons/base/ir/ir_model.py (+14/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-fields_name_constraint_-ach
Reviewer Review Type Date Requested Status
OpenERP buildbot (community) Disapprove
Olivier Dony (Odoo) Pending
Jay Vora (Serpent Consulting Services) Pending
xrg Pending
Christophe Simonis (OpenERP) Pending
Review via email: mp+53967@code.launchpad.net

Description of the change

Hello,

    Now the Constraint restricts the following,

1. Custom field name must start with 'x_'.
2. All field name must not contain special characters or white spaces.
3. All field name must be in lowercase.
4. All the fieldname must start with either alphabets or '_' and not digits.

Your views please.
Thanks.

To post a comment you must log in.
Revision history for this message
OpenERP buildbot (openerp-buildbot) :
review: Disapprove

Unmerged revisions

3372. By Anup(SerpentCS)

[FIX] base : optimized and restricted the fields not containing any special characters and must be with lowercase letters only

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/ir/ir_model.py'
2--- bin/addons/base/ir/ir_model.py 2011-01-20 16:27:06 +0000
3+++ bin/addons/base/ir/ir_model.py 2011-03-18 10:02:25 +0000
4@@ -220,6 +220,20 @@
5 }
6 _order = "name"
7
8+
9+ def _check_field_name(self, cr, uid, ids, context=None):
10+ for field in self.browse(cr, uid, ids, context=context):
11+ if field.state=='manual':
12+ if not field.name.startswith('x_'):
13+ return False
14+ if not re.match('^[a-z_][a-z_0-9]+$',field.name):
15+ return False
16+ return True
17+
18+ _constraints = [
19+ (_check_field_name, _('The Field name must start with x_ and not contain any special character !'), ['name']),
20+ ]
21+
22 def _check_selection(self, cr, uid, selection, context=None):
23 try:
24 selection_list = eval(selection)