← Back to team overview

openerp-dev-web team mailing list archive

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

 

Anup(OpenERP) has proposed merging lp:~openerp-dev/openobject-server/6.0-opw-fields_name_containing_special_chars_-ach into lp:openobject-server/6.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-fields_name_containing_special_chars_-ach/+merge/53801

Hello

    Currently we are allowing fieldsname having special character. Specially white spaces. This is creating a problem. The field is being created but it is crashing the system.
    I have found a solution to restrict the fields having no special characters.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-fields_name_containing_special_chars_-ach/+merge/53801
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/6.0-opw-fields_name_containing_special_chars_-ach.
=== modified file 'bin/addons/base/ir/ir_model.py'
--- bin/addons/base/ir/ir_model.py	2011-01-20 16:27:06 +0000
+++ bin/addons/base/ir/ir_model.py	2011-03-17 12:32:59 +0000
@@ -220,6 +220,20 @@
     }
     _order = "name"
 
+
+    def _check_field_name(self, cr, uid, ids, context=None):
+        for field in self.browse(cr, uid, ids, context=context):
+            if field.state=='manual':
+                if not field.name.startswith('x_'):
+                    return False
+            if not re.match('^[a-z_A-Z0-9.]+$',field.name):
+                return False
+        return True
+
+    _constraints = [
+        (_check_field_name, _('The Field name must start with x_ and not contain any special character !'), ['name']),
+    ]
+    
     def _check_selection(self, cr, uid, selection, context=None):
         try:
             selection_list = eval(selection)


Follow ups