[FIX] account: name_search methods used '=' or 'ilike' to search, instead of the actual operator
Therefore, for example, searching invoices for journals doesnt containing 'sales' actually returned invoices with journal containing 'sales'. bzr revid: dle@openerp.com-20140414121930-xbawuj93ddifhf4m
This commit is contained in:
parent
3a27186643
commit
c3300dce7a
|
@ -845,16 +845,11 @@ class account_journal(osv.osv):
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
||||||
if not args:
|
if not args:
|
||||||
args = []
|
args = []
|
||||||
if context is None:
|
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||||
context = {}
|
domain = [('code', operator, name), ('name', operator, name)]
|
||||||
ids = []
|
else:
|
||||||
if context.get('journal_type', False):
|
domain = ['|', ('code', operator, name), ('name', operator, name)]
|
||||||
args += [('type','=',context.get('journal_type'))]
|
ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context)
|
||||||
if name:
|
|
||||||
ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit, context=context)
|
|
||||||
if not ids:
|
|
||||||
ids = self.search(cr, user, [('name', 'ilike', name)]+ args, limit=limit, context=context)#fix it ilike should be replace with operator
|
|
||||||
|
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
account_journal()
|
account_journal()
|
||||||
|
@ -944,13 +939,11 @@ class account_fiscalyear(osv.osv):
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
if args is None:
|
if args is None:
|
||||||
args = []
|
args = []
|
||||||
if context is None:
|
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||||
context = {}
|
domain = [('code', operator, name), ('name', operator, name)]
|
||||||
ids = []
|
else:
|
||||||
if name:
|
domain = ['|', ('code', operator, name), ('name', operator, name)]
|
||||||
ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit)
|
ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context)
|
||||||
if not ids:
|
|
||||||
ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit)
|
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
account_fiscalyear()
|
account_fiscalyear()
|
||||||
|
@ -1045,19 +1038,11 @@ class account_period(osv.osv):
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
|
||||||
if args is None:
|
if args is None:
|
||||||
args = []
|
args = []
|
||||||
if context is None:
|
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||||
context = {}
|
domain = [('code', operator, name), ('name', operator, name)]
|
||||||
ids = []
|
else:
|
||||||
if name:
|
domain = ['|', ('code', operator, name), ('name', operator, name)]
|
||||||
ids = self.search(cr, user,
|
ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context)
|
||||||
[('code', 'ilike', name)] + args,
|
|
||||||
limit=limit,
|
|
||||||
context=context)
|
|
||||||
if not ids:
|
|
||||||
ids = self.search(cr, user,
|
|
||||||
[('name', operator, name)] + args,
|
|
||||||
limit=limit,
|
|
||||||
context=context)
|
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
|
@ -1195,36 +1180,6 @@ class account_move(osv.osv):
|
||||||
'company_id': company_id,
|
'company_id': company_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
|
||||||
"""
|
|
||||||
Returns a list of tupples containing id, name, as internally it is called {def name_get}
|
|
||||||
result format: {[(id, name), (id, name), ...]}
|
|
||||||
|
|
||||||
@param cr: A database cursor
|
|
||||||
@param user: ID of the user currently logged in
|
|
||||||
@param name: name to search
|
|
||||||
@param args: other arguments
|
|
||||||
@param operator: default operator is 'ilike', it can be changed
|
|
||||||
@param context: context arguments, like lang, time zone
|
|
||||||
@param limit: Returns first 'n' ids of complete result, default is 80.
|
|
||||||
|
|
||||||
@return: Returns a list of tuples containing id and name
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not args:
|
|
||||||
args = []
|
|
||||||
ids = []
|
|
||||||
if name:
|
|
||||||
ids += self.search(cr, user, [('name','ilike',name)]+args, limit=limit, context=context)
|
|
||||||
|
|
||||||
if not ids and name and type(name) == int:
|
|
||||||
ids += self.search(cr, user, [('id','=',name)]+args, limit=limit, context=context)
|
|
||||||
|
|
||||||
if not ids:
|
|
||||||
ids += self.search(cr, user, args, limit=limit, context=context)
|
|
||||||
|
|
||||||
return self.name_get(cr, user, ids, context=context)
|
|
||||||
|
|
||||||
def name_get(self, cursor, user, ids, context=None):
|
def name_get(self, cursor, user, ids, context=None):
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
|
@ -1853,10 +1808,12 @@ class account_tax_code(osv.osv):
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args = []
|
args = []
|
||||||
if context is None:
|
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||||
context = {}
|
domain = [('code', operator, name), ('name', operator, name)]
|
||||||
ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context)
|
else:
|
||||||
return self.name_get(cr, user, ids, context)
|
domain = ['|', ('code', operator, name), ('name', operator, name)]
|
||||||
|
ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context)
|
||||||
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context=None):
|
def name_get(self, cr, uid, ids, context=None):
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
|
@ -1986,15 +1943,11 @@ class account_tax(osv.osv):
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not args:
|
||||||
args = []
|
args = []
|
||||||
if context is None:
|
if operator in expression.NEGATIVE_TERM_OPERATORS:
|
||||||
context = {}
|
domain = [('description', operator, name), ('name', operator, name)]
|
||||||
ids = []
|
|
||||||
if name:
|
|
||||||
ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context)
|
|
||||||
if not ids:
|
|
||||||
ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
|
|
||||||
else:
|
else:
|
||||||
ids = self.search(cr, user, args, limit=limit, context=context or {})
|
domain = ['|', ('description', operator, name), ('name', operator, name)]
|
||||||
|
ids = self.search(cr, user, expression.AND([domain, args]), limit=limit, context=context)
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
|
|
Loading…
Reference in New Issue