From a3229487ec6ef480158263e07b8595c7bbdd0c9f Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 28 Nov 2011 17:00:01 +0100 Subject: [PATCH] [REF] l10n_fr_rib: refactored bank name_search as suggested by Olivier Dony (OpenERP) [IMP] l10n_fr_rib: don't re-check error condition when constructing the message for key mismatch [FIx] l10n_fr_rib: wrong field name for bank code bzr revid: ls@numerigraphe.fr-20111128160001-q7re8fxr9lv2ad9g --- addons/l10n_fr_rib/bank.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/addons/l10n_fr_rib/bank.py b/addons/l10n_fr_rib/bank.py index ea32bca4467..4875dc33512 100644 --- a/addons/l10n_fr_rib/bank.py +++ b/addons/l10n_fr_rib/bank.py @@ -61,7 +61,7 @@ class res_partner_bank(osv.osv): if bank_id: bank = self.pool.get('res.bank').browse(cr, uid, bank_id, context=context) - result['bank_code'] = bank.code + result['bank_code'] = bank.rib_code return {'value': result} _columns = { @@ -74,8 +74,6 @@ class res_partner_bank(osv.osv): def _construct_constraint_msg(self, cr, uid, ids, context=None): """Quote the data in the warning message""" - if self._check_key(cr, uid, ids): - return # Only process the first id if type(ids) not in (int, long): id = ids[0] @@ -100,17 +98,17 @@ class res_bank(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): - """Search by bank code""" - if args is None: - args = [] - ids = [] - if name: - ids = self.search(cr, user, [('name', operator, name)] + args, + """Search by bank code in addition to the standard search""" + # Get the standard results + results = super(res_bank, self).name_search(cr, user, + name, args=args ,operator=operator, context=context, limit=limit) + # Get additional results using the RIB code + ids = self.search(cr, user, [('rib_code', operator, name)], limit=limit, context=context) - if not ids: - ids = self.search(cr, user, [('code', operator, name)] + args, - limit=limit, context=context) - return self.name_get(cr, user, ids, context) + # Merge the results + results = list(set(results + self.name_get(cr, user, ids, context))) + print results + return results _columns = { 'rib_code': fields.char('RIB Bank Code', size=64),