I reopen the bug because, in my opinion, res.partner.contact should have a name_search method defined and the behavior will be the same, but with improvements because, if the args in search method were:
This query will be unnecessary, because I search for contacts by id, then the search method does a second query with super search and it does a set of two results.
It is very slow. I analyze it with pgfouine only the first query. See the result:
SELECT res_partner_contact.id FROM "res_partner_contact" WHERE (res_partner_contact.active = E'') AND ((res_partner_contact.first_name ilike E'') OR (res_partner_contact.name ilike E'')) ORDER BY id;
Av. duration (s): 0.89
Times executed: 50
Total duration: 44.3s
Very Slow.
I think that the search method should be erased because with a name_search in contact, it is very fast because don't do this behavior the name_search should be like this:
def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None):
args = args or []
if name:
ids = [] ids.extend(self.search(cr, uid, ['|',('name', operator, name),('first_name', operator, name)] + args, limit=limit, context=context or {}))
else:
ids = self.search(cr, uid, args, limit=limit, context=context or {})
return self.name_get(cr, uid, ids, context or {})
Hi,
I reopen the bug because, in my opinion, res.partner.contact should have a name_search method defined and the behavior will be the same, but with improvements because, if the args in search method were:
[('contact_id', 'in', [2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 20536, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391,...])]
The result query was:
SELECT res_partner_ contact. id FROM "res_partner_ contact" WHERE (res_partner_ contact. active = E'True') AND ((res_partner_ contact. first_name ilike E'%[2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 20536, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391,..]%') OR (res_partner_ contact. name ilike E'%[2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 20536, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391,...]%')) ORDER BY id;
This query will be unnecessary, because I search for contacts by id, then the search method does a second query with super search and it does a set of two results.
Second query was:
select res_partner_job.id from "res_partner_job" where (res_partner_ job.contact_ id in (2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 20536, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391,...)) order by sequence_contact
It is very slow. I analyze it with pgfouine only the first query. See the result:
SELECT res_partner_ contact. id FROM "res_partner_ contact" WHERE (res_partner_ contact. active = E'') AND ((res_partner_ contact. first_name ilike E'') OR (res_partner_ contact. name ilike E'')) ORDER BY id;
Av. duration (s): 0.89
Times executed: 50
Total duration: 44.3s
Very Slow.
I think that the search method should be erased because with a name_search in contact, it is very fast because don't do this behavior the name_search should be like this:
def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None):
ids. extend( self.search( cr, uid, ['|',('name', operator, name),( 'first_ name', operator, name)] + args, limit=limit, context=context or {}))
args = args or []
if name:
ids = []
else:
ids = self.search(cr, uid, args, limit=limit, context=context or {})
return self.name_get(cr, uid, ids, context or {})