[FIX] allow to use server-side domains with widget='selection' fields
[FIX] widget='selection' fields now handle correctly the required fields bzr revid: christophe@tinyerp.com-20090428144014-7wxt52bfy5odnf5r
This commit is contained in:
parent
022e7ff2cb
commit
efc01f25ae
|
@ -800,13 +800,14 @@ class orm_template(object):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
try:
|
try:
|
||||||
if node.getAttribute('name') in self._columns:
|
if node.getAttribute('name') in self._columns:
|
||||||
relation = self._columns[node.getAttribute('name')]._obj
|
column = self._columns[node.getAttribute('name')]
|
||||||
else:
|
else:
|
||||||
relation = self._inherit_fields[node.getAttribute('name')][2]._obj
|
column = self._inherit_fields[node.getAttribute('name')][2]
|
||||||
except:
|
except:
|
||||||
relation = False
|
column = False
|
||||||
|
|
||||||
if relation:
|
if column:
|
||||||
|
relation = column._obj
|
||||||
childs = False
|
childs = False
|
||||||
views = {}
|
views = {}
|
||||||
for f in node.childNodes:
|
for f in node.childNodes:
|
||||||
|
@ -821,9 +822,12 @@ class orm_template(object):
|
||||||
}
|
}
|
||||||
attrs = {'views': views}
|
attrs = {'views': views}
|
||||||
if node.hasAttribute('widget') and node.getAttribute('widget')=='selection':
|
if node.hasAttribute('widget') and node.getAttribute('widget')=='selection':
|
||||||
# We can not use the domain has it is defined according to the record !
|
# We can not use the 'string' domain has it is defined according to the record !
|
||||||
attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', context=context)
|
dom = None
|
||||||
if not attrs.get('required',False):
|
if column._domain and not isinstance(column._domain, (str, unicode)):
|
||||||
|
dom = column._domain
|
||||||
|
attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', dom, context=context)
|
||||||
|
if (node.hasAttribute('required') and not int(node.getAttribute('required'))) or not column.required:
|
||||||
attrs['selection'].append((False,''))
|
attrs['selection'].append((False,''))
|
||||||
fields[node.getAttribute('name')] = attrs
|
fields[node.getAttribute('name')] = attrs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue