[MERGE] forward port of branch 7.0 up to 9cc54dc
authorDenis Ledoux <dle@odoo.com>
Wed, 1 Oct 2014 10:41:42 +0000 (12:41 +0200)
committerDenis Ledoux <dle@odoo.com>
Wed, 1 Oct 2014 10:41:42 +0000 (12:41 +0200)
1  2 
addons/hr_expense/hr_expense.py
addons/hr_payroll_account/hr_payroll_account.py
addons/product/product.py
addons/purchase/purchase.py

Simple merge
@@@ -24,9 -24,8 +24,9 @@@ import r
  
  from _common import ceiling
  
 -from openerp import tools, SUPERUSER_ID
 -from openerp.osv import osv, fields, expression
 +from openerp import SUPERUSER_ID
 +from openerp import tools
- from openerp.osv import osv, orm, fields
++from openerp.osv import osv, orm, fields, expression
  from openerp.tools.translate import _
  
  import openerp.addons.decimal_precision as dp
@@@ -779,13 -683,15 +782,15 @@@ class product_product(osv.osv)
                  # on a database with thousands of matching products, due to the huge merge+unique needed for the
                  # OR operator (and given the fact that the 'name' lookup results come from the ir.translation table
                  # Performing a quick memory merge of ids in Python will give much better performance
 -                ids = set()
 -                ids.update(self.search(cr, user, args + [('default_code',operator,name)], limit=limit, context=context))
 +                ids = set(self.search(cr, user, args + [('default_code', operator, name)], limit=limit, context=context))
                  if not limit or len(ids) < limit:
                      # we may underrun the limit because of dupes in the results, that's fine
 -                    ids.update(self.search(cr, user, args + [('name',operator,name)], limit=(limit and (limit-len(ids)) or False) , context=context))
 +                    limit2 = (limit - len(ids)) if limit else False
 +                    ids.update(self.search(cr, user, args + [('name', operator, name)], limit=limit2, context=context))
                  ids = list(ids)
-             if not ids:
+             elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS:
+                 ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context)
+             if not ids and operator in positive_operators:
                  ptrn = re.compile('(\[(.*?)\])')
                  res = ptrn.search(name)
                  if res:
Simple merge