<commit_before># -*- encoding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2012
#    Associazione OpenERP Italia (<http://www.openerp-italia.org>)
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################

from osv import fields, osv


class res_bank(osv.osv):
    _inherit = "res.bank"
    _columns = {
        'abi': fields.char('ABI', size=5),
        'cab': fields.char('CAB', size=5),
        'province': fields.many2one('res.province', string='Provincia', ondelete='restrict'),
    }


class res_partner_bank(osv.osv):
    _inherit = "res.partner.bank"
    _columns = {
        'bank_abi': fields.char('ABI', size=5),
        'bank_cab': fields.char('CAB', size=5),
    }

    def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):<commit_msg>increase search function on bank<commit_after># -*- encoding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2012
#    Associazione OpenERP Italia (<http://www.openerp-italia.org>)
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################

from osv import fields, osv


class res_bank(osv.osv):
    _inherit = "res.bank"
    _columns = {
        'abi': fields.char('ABI', size=5),
        'cab': fields.char('CAB', size=5),
        'province': fields.many2one('res.province', string='Provincia', ondelete='restrict'),
    }

    def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None):
        if not args:
            args = []
        context = context or self.pool['res.users'].context_get(cr, uid)
        if name:
            abi_cab = name.split(' ')
            if len(abi_cab) == 2 and abi_cab[0].isdigit() and abi_cab[1].isdigit():
                ids = self.search(cr, uid, [('abi', '=', abi_cab[0]), ('cab', '=', abi_cab[1])], limit=limit, context=context)
            else:
                ids = self.search(cr, uid, ['|', '|', ('abi', '=', name), ('cab', '=', name), ('name', 'like', name)] + args, limit=limit, context=context)
        else:
            ids = self.search(cr, uid, args, limit=limit, context=context)
        return self.name_get(cr, uid, ids, context=context)

    def name_get(self, cr, uid, ids, context=None):
        res = []
        for bank in self.browse(cr, uid, ids, context=context):
            if bank.abi and bank.cab:
                name = u"[{abi} {cab}] {name}".format(abi=bank.abi, cab=bank.cab, name=bank.name)
            else:
                name = bank.name
            res.append((bank.id, name))
        return res


class res_partner_bank(osv.osv):
    _inherit = "res.partner.bank"
    _columns = {
        'bank_abi': fields.char('ABI', size=5),
        'bank_cab': fields.char('CAB', size=5),
    }

    def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
{'fraction_non_alphanumeric': 0.19358533791523483, 'fraction_numerical': 0.006185567010309278, 'mean_word_length': 3.2061657032755297, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5313729', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1297, 'n_words': 408}