[FIX] _search not uniquifies the results, because when using _auto_join we could have duplicates in the 'left part' of the result, i.e. a lead with several unread messages. This is done using a custom method instead of a set, because sets are unordered.

bzr revid: tde@openerp.com-20121220141842-or3bigz11qkb13qn
This commit is contained in:
Thibault Delavallée
2012-12-20 15:18:42 +01:00
parent e29f0565c9
commit 36e5b6e88e
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -61,5 +61,5 @@ class ir_needaction_mixin(osv.AbstractModel):
dom = self._needaction_domain_get(cr, uid, context=context)
if not dom:
return 0
res = self.search(cr, uid, (domain or []) + dom, limit=100, order='id DESC', context=context)
res = self.search(cr, uid, (domain or []) + dom, limit=1000, order='id DESC', context=context)
return len(res)
+9 -1
View File
@@ -4857,7 +4857,15 @@ class BaseModel(object):
return res[0][0]
cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params)
res = cr.fetchall()
return [x[0] for x in res]
# TDE note: with auto_join, we could have several lines about the same result
# i.e. a lead with several unread messages; we uniquify the result using
# a fast way to do it while preserving order (http://www.peterbe.com/plog/uniqifiers-benchmark)
def _uniquify_list(seq):
seen = set()
return [x for x in seq if x not in seen and not seen.add(x)]
return _uniquify_list([x[0] for x in res])
# returns the different values ever entered for one field
# this is used, for example, in the client when the user hits enter on