}
attrs = {'views': views}
if node.get('widget') and node.get('widget') == 'selection':
- if not check_group(node):
- name = node.get('name')
- default = self.default_get(cr, user, [name], context=context).get(name)
- if default:
- attrs['selection'] = relation.name_get(cr, 1, [default], context=context)
- else:
- attrs['selection'] = []
- # We can not use the 'string' domain has it is defined according to the record !
- else:
- # If domain and context are strings, we keep them for client-side, otherwise
- # we evaluate them server-side to consider them when generating the list of
- # possible values
- # TODO: find a way to remove this hack, by allow dynamic domains
- dom = []
- if column._domain and not isinstance(column._domain, basestring):
- dom = column._domain
- dom += eval(node.get('domain','[]'), {'uid':user, 'time':time})
- search_context = dict(context)
- if column._context and not isinstance(column._context, basestring):
- search_context.update(column._context)
- attrs['selection'] = relation._name_search(cr, 1, '', dom, context=search_context, limit=None, name_get_uid=1)
- if (node.get('required') and not int(node.get('required'))) or not column.required:
- attrs['selection'].append((False,''))
+ # Prepare the cached selection list for the client. This needs to be
+ # done even when the field is invisible to the current user, because
+ # other events could need to change its value to any of the selectable ones
+ # (such as on_change events, refreshes, etc.)
+
+ # If domain and context are strings, we keep them for client-side, otherwise
+ # we evaluate them server-side to consider them when generating the list of
+ # possible values
+ # TODO: find a way to remove this hack, by allow dynamic domains
+ dom = []
+ if column._domain and not isinstance(column._domain, basestring):
+ dom = column._domain
+ dom += eval(node.get('domain','[]'), {'uid':user, 'time':time})
+ search_context = dict(context)
+ if column._context and not isinstance(column._context, basestring):
+ search_context.update(column._context)
+ attrs['selection'] = relation._name_search(cr, 1, '', dom, context=search_context, limit=None, name_get_uid=1)
+ if (node.get('required') and not int(node.get('required'))) or not column.required:
+ attrs['selection'].append((False,''))
fields[node.get('name')] = attrs
elif node.tag in ('form', 'tree'):