Use function name instead of address in _constraints
This commit is contained in:
@@ -29,8 +29,11 @@ class View(OSV):
|
||||
'module': lambda obj, cursor, user, context: context.get('module', ''),
|
||||
}
|
||||
_order = "priority"
|
||||
_constraints = [
|
||||
('check_xml', 'Invalid XML for View Architecture!', ['arch'])
|
||||
]
|
||||
|
||||
def _check_xml(self, cursor, user, ids):
|
||||
def check_xml(self, cursor, user, ids):
|
||||
"Check XML"
|
||||
views = self.browse(cursor, user, ids)
|
||||
cursor.execute('SELECT id, name, src FROM ir_translation ' \
|
||||
@@ -100,10 +103,6 @@ class View(OSV):
|
||||
(view.model, 'view') + tuple(strings))
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
|
||||
]
|
||||
|
||||
def unlink(self, cursor, user, ids, context=None):
|
||||
|
||||
if isinstance(ids, (int, long)):
|
||||
|
||||
+1
-1
@@ -1177,7 +1177,7 @@ class ORM(object):
|
||||
field_error = []
|
||||
field_err_str = []
|
||||
for field in self._constraints:
|
||||
if not field[0](self, cursor, user, ids):
|
||||
if not getattr(self, field[0])(cursor, user, ids):
|
||||
if len(field) > 1:
|
||||
field_error += field[2]
|
||||
field_err_str.append(field[1])
|
||||
|
||||
@@ -25,13 +25,9 @@ class Directory(OSV):
|
||||
('name_parent_uniq', 'UNIQUE (name, parent)',
|
||||
'The directory name must be unique inside a directory!'),
|
||||
]
|
||||
|
||||
def check_recursion(self, cursor, user, ids, parent=None):
|
||||
return super(Directory, self).check_recursion(cursor, user, ids,
|
||||
parent='parent')
|
||||
|
||||
_parent_name = 'parent'
|
||||
_constraints = [
|
||||
(check_recursion,
|
||||
('check_recursion',
|
||||
'Error! You can not create recursive directories.', ['parent']),
|
||||
]
|
||||
ext2mime = {
|
||||
|
||||
Reference in New Issue
Block a user