From efc01f25aea7aa5ac44a3edc9b19327b6b5bc58c Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 28 Apr 2009 16:40:14 +0200 Subject: [PATCH] [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 --- bin/osv/orm.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index b3b92dc00cc..cfc311102eb 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -800,13 +800,14 @@ class orm_template(object): attrs = {} try: if node.getAttribute('name') in self._columns: - relation = self._columns[node.getAttribute('name')]._obj + column = self._columns[node.getAttribute('name')] else: - relation = self._inherit_fields[node.getAttribute('name')][2]._obj + column = self._inherit_fields[node.getAttribute('name')][2] except: - relation = False + column = False - if relation: + if column: + relation = column._obj childs = False views = {} for f in node.childNodes: @@ -821,9 +822,12 @@ class orm_template(object): } attrs = {'views': views} if node.hasAttribute('widget') and node.getAttribute('widget')=='selection': - # We can not use the domain has it is defined according to the record ! - attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', context=context) - if not attrs.get('required',False): + # We can not use the 'string' domain has it is defined according to the record ! + dom = None + 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,'')) fields[node.getAttribute('name')] = attrs