diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index d4b519764a8..037d2a90986 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -515,10 +515,8 @@ class one2many(_column): for id in ids: res[id] = [] - dom = self._domain - if isinstance(self._domain, type(lambda: None)): - dom = self._domain(obj) - ids2 = obj.pool.get(self._obj).search(cr, user, dom + [(self._fields_id, 'in', ids)], limit=self._limit, context=context) + domain = self._domain(obj) if callable(self._domain) else self._domain + ids2 = obj.pool.get(self._obj).search(cr, user, domain + [(self._fields_id, 'in', ids)], limit=self._limit, context=context) for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): if r[self._fields_id] in res: res[r[self._fields_id]].append(r['id']) @@ -560,10 +558,8 @@ class one2many(_column): reverse_rel = obj._all_columns.get(self._fields_id) assert reverse_rel, 'Trying to unlink the content of a o2m but the pointed model does not have a m2o' # if the o2m has a static domain we must respect it when unlinking - dom = self._domain - if isinstance(self._domain, type(lambda: None)): - dom = self._domain(obj) - extra_domain = dom or [] + domain = self._domain(obj) if callable(self._domain) else self._domain + extra_domain = domain or [] ids_to_unlink = obj.search(cr, user, [(self._fields_id,'=',id)] + extra_domain, context=context) # If the model has cascade deletion, we delete the rows because it is the intended behavior, # otherwise we only nullify the reverse foreign key column. @@ -581,10 +577,8 @@ class one2many(_column): return result def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, operator='like', context=None): - dom = self._domain - if isinstance(self._domain, type(lambda: None)): - dom = self._domain(obj) - return obj.pool.get(self._obj).name_search(cr, uid, value, dom, operator, context=context,limit=limit) + domain = self._domain(obj) if callable(self._domain) else self._domain + return obj.pool.get(self._obj).name_search(cr, uid, value, domain, operator, context=context,limit=limit) @classmethod @@ -1549,14 +1543,12 @@ def field_to_dict(model, cr, user, field, context=None): """ res = {'type': field._type} - # This additional attributes for M2M and function field is added - # because we need to display tooltip with this additional information - # when client is started in debug mode. + # some attributes for m2m/function field are added as debug info only if isinstance(field, function): res['function'] = field._fnct and field._fnct.func_name or False - # res['store'] = field.store - # if isinstance(field.store, dict): - # res['store'] = str(field.store) + res['store'] = field.store + if isinstance(field.store, dict): + res['store'] = str(field.store) res['fnct_search'] = field._fnct_search and field._fnct_search.func_name or False res['fnct_inv'] = field._fnct_inv and field._fnct_inv.func_name or False res['fnct_inv_arg'] = field._fnct_inv_arg or False @@ -1586,10 +1578,7 @@ def field_to_dict(model, cr, user, field, context=None): res['selection'] = field.selection(model, cr, user, context) if res['type'] in ('one2many', 'many2many', 'many2one'): res['relation'] = field._obj - dom = field._domain - if isinstance(field._domain, type(lambda: None)): - dom = field._domain(model) - res['domain'] = dom + res['domain'] = field._domain(model) if callable(field._domain) else field._domain res['context'] = field._context if isinstance(field, one2many):