Browse Source

[FIX] deal with limit=0/None correctly

pull/980/head
Holger Brunn 7 years ago
parent
commit
8ab7958fb2
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 2
      base_name_search_improved/__openerp__.py
  2. 6
      base_name_search_improved/models/ir_model.py

2
base_name_search_improved/__openerp__.py

@ -4,7 +4,7 @@
{ {
'name': 'Improved Name Search', 'name': 'Improved Name Search',
'summary': 'Friendlier search when typing in relation fields', 'summary': 'Friendlier search when typing in relation fields',
'version': '8.0.1.0.1',
'version': '8.0.1.0.2',
'category': 'Uncategorized', 'category': 'Uncategorized',
'website': 'https://odoo-community.org/', 'website': 'https://odoo-community.org/',
'author': 'Daniel Reis, Odoo Community Association (OCA)', 'author': 'Daniel Reis, Odoo Community Association (OCA)',

6
base_name_search_improved/models/ir_model.py

@ -23,9 +23,11 @@ def _get_rec_names(self):
def _extend_name_results(self, domain, results, limit): def _extend_name_results(self, domain, results, limit):
result_count = len(results) result_count = len(results)
if result_count < limit:
if not limit or result_count < limit:
domain += [('id', 'not in', [x[0] for x in results])] domain += [('id', 'not in', [x[0] for x in results])]
recs = self.search(domain, limit=limit - result_count)
recs = self.search(
domain, limit=limit - result_count if limit else limit
)
results.extend(recs.name_get()) results.extend(recs.name_get())
return results return results

Loading…
Cancel
Save