From 66ce0ac970c01890b8e2a8c0baed4727551fdc91 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Sat, 3 Jan 2015 20:56:46 +0100 Subject: [PATCH] [FIX] account: name_search for multilang CoA The `account.account` `name` can be translated as soon as `l10n_multilang` is installed. Not passing the context in the calls to the `search` method prevented to search on the translations of this name. Closes #4511 --- addons/account/account.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 83e362c5e59..87f31daa6d9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -580,6 +580,8 @@ class account_account(osv.osv): ('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !') ] def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): + if context is None: + context = {} if not args: args = [] args = args[:] @@ -604,18 +606,18 @@ class account_account(osv.osv): 'like': ('=like', plus_percent), }.get(operator, (operator, lambda n: n)) - ids = self.search(cr, user, ['|', ('code', code_op, code_conv(name)), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit) + ids = self.search(cr, user, ['|', ('code', code_op, code_conv(name)), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit, context=context) if not ids and len(name.split()) >= 2: #Separating code and name of account for searching operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A. - ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2)]+ args, limit=limit) + ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2)]+ args, limit=limit, context=context) else: - ids = self.search(cr, user, ['&','!', ('code', '=like', name+"%"), ('name', operator, name)]+args, limit=limit) + ids = self.search(cr, user, ['&','!', ('code', '=like', name+"%"), ('name', operator, name)]+args, limit=limit, context=context) # as negation want to restric, do if already have results if ids and len(name.split()) >= 2: operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A. - ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2), ('id', 'in', ids)]+ args, limit=limit) + ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2), ('id', 'in', ids)]+ args, limit=limit, context=context) else: ids = self.search(cr, user, args, context=context, limit=limit) return self.name_get(cr, user, ids, context=context)