[FIX] expression: properly care for implicitly defined m2m fields used in search() domains
Now that m2m fields may be defined without explicitly specifying the name of the relationship table and its foreign key columns, all access to these internal names should be done via m2m._sql_names(). This seems better than lazily initializing these internal names and hoping that nothing accesses them before the init. bzr revid: odo@openerp.com-20120119151012-c38k5zl7rqherhth
This commit is contained in:
parent
f9cbad5bf6
commit
c68045e497
|
@ -526,12 +526,13 @@ class expression(object):
|
|||
self.__exp[i] = ('id', o2m_op, select_distinct_from_where_not_null(cr, field._fields_id, field_obj._table))
|
||||
|
||||
elif field._type == 'many2many':
|
||||
rel_table, rel_id1, rel_id2 = field._sql_names(working_table)
|
||||
#FIXME
|
||||
if operator == 'child_of':
|
||||
def _rec_convert(ids):
|
||||
if field_obj == table:
|
||||
return ids
|
||||
return select_from_where(cr, field._id1, field._rel, field._id2, ids, operator)
|
||||
return select_from_where(cr, rel_id1, rel_table, rel_id2, ids, operator)
|
||||
|
||||
ids2 = to_ids(right, field_obj)
|
||||
dom = child_of_domain('id', ids2, field_obj)
|
||||
|
@ -559,11 +560,11 @@ class expression(object):
|
|||
else:
|
||||
call_null_m2m = False
|
||||
m2m_op = 'not in' if operator in NEGATIVE_TERM_OPERATORS else 'in'
|
||||
self.__exp[i] = ('id', m2m_op, select_from_where(cr, field._id1, field._rel, field._id2, res_ids, operator) or [0])
|
||||
self.__exp[i] = ('id', m2m_op, select_from_where(cr, rel_id1, rel_table, rel_id2, res_ids, operator) or [0])
|
||||
|
||||
if call_null_m2m:
|
||||
m2m_op = 'in' if operator in NEGATIVE_TERM_OPERATORS else 'not in'
|
||||
self.__exp[i] = ('id', m2m_op, select_distinct_from_where_not_null(cr, field._id1, field._rel))
|
||||
self.__exp[i] = ('id', m2m_op, select_distinct_from_where_not_null(cr, rel_id1, rel_table))
|
||||
|
||||
elif field._type == 'many2one':
|
||||
if operator == 'child_of':
|
||||
|
|
Loading…
Reference in New Issue