diff --git a/openerp/addons/test_inherit/tests/test_inherit.py b/openerp/addons/test_inherit/tests/test_inherit.py index f6057817ee4..8e12b0b7e08 100644 --- a/openerp/addons/test_inherit/tests/test_inherit.py +++ b/openerp/addons/test_inherit/tests/test_inherit.py @@ -74,6 +74,12 @@ class test_inherits(common.TransactionCase): self.assertIn(daughter, partner_demo.daughter_ids) # search the partner from the daughter record + partners = self.env['res.partner'].search([('daughter_ids', 'like', 'not existing daugther')]) + self.assertFalse(partners) + partners = self.env['res.partner'].search([('daughter_ids', 'not like', 'not existing daugther')]) + self.assertIn(partner_demo, partners) + partners = self.env['res.partner'].search([('daughter_ids', '!=', False)]) + self.assertIn(partner_demo, partners) partners = self.env['res.partner'].search([('daughter_ids', 'in', daughter.ids)]) self.assertIn(partner_demo, partners) diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index f29fc8f7084..2be571e538c 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -981,7 +981,14 @@ class expression(object): if call_null: o2m_op = 'in' if operator in NEGATIVE_TERM_OPERATORS else 'not in' - push(create_substitution_leaf(leaf, ('id', o2m_op, select_distinct_from_where_not_null(cr, column._fields_id, comodel._table)), model)) + # determine ids from column._fields_id + if comodel._fields[column._fields_id].store: + ids1 = select_distinct_from_where_not_null(cr, column._fields_id, comodel._table) + else: + ids2 = comodel.search(cr, uid, [(column._fields_id, '!=', False)], context=context) + recs = comodel.browse(cr, SUPERUSER_ID, ids2, {'prefetch_fields': False}) + ids1 = recs.mapped(column._fields_id).ids + push(create_substitution_leaf(leaf, ('id', o2m_op, ids1), model)) elif column._type == 'many2many': rel_table, rel_id1, rel_id2 = column._sql_names(model)