mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[RFR] Remove founder class hack. This will introduce some duplicated
functionality between the deprecated module and base_iban [IMP] Disregard spaces when comparing IBAN, as we can now no longer assume that IBANs are in the legacy account_banking formatting
This commit is contained in:
@@ -52,11 +52,20 @@ class ResPartnerBank(orm.Model):
|
||||
'''
|
||||
Extend the search criteria in term when appropriate.
|
||||
'''
|
||||
result = [term]
|
||||
extra_terms = []
|
||||
if term[0].lower() == 'acc_number' and term[1] in ('=', '=='):
|
||||
iban = sepa.IBAN(term[2])
|
||||
if iban.valid:
|
||||
extra_terms.append(('acc_number', term[1], iban.__repr__()))
|
||||
# Disregard spaces when comparing IBANs
|
||||
cr.execute(
|
||||
"""
|
||||
SELECT id FROM res_partner_bank
|
||||
WHERE replace(acc_number, ' ', '') = %s
|
||||
""", (term[2].replace(' ', ''),))
|
||||
ids = [row[0] for row in cr.fetchall()]
|
||||
result = [('id', 'in', ids)]
|
||||
|
||||
if 'acc_number_domestic' in self._columns:
|
||||
# Some countries can't convert to BBAN
|
||||
try:
|
||||
@@ -66,7 +75,6 @@ class ResPartnerBank(orm.Model):
|
||||
extra_terms.append(('acc_number_domestic', term[1], bban))
|
||||
except:
|
||||
pass
|
||||
result = [term]
|
||||
for extra_term in extra_terms:
|
||||
result = ['|'] + result + [extra_term]
|
||||
return result
|
||||
|
||||
@@ -50,21 +50,6 @@ class res_partner_bank(orm.Model):
|
||||
'''
|
||||
_inherit = 'res.partner.bank'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
'''
|
||||
Locate founder (first non inherited class) in inheritance tree.
|
||||
Defaults to super()
|
||||
Algorithm should prevent moving unknown classes between
|
||||
base.res_partner_bank and this module's res_partner_bank.
|
||||
'''
|
||||
self._founder = super(res_partner_bank, self)
|
||||
self._founder.__init__(*args, **kwargs)
|
||||
mro = self.__class__.__mro__
|
||||
for i in range(len(mro)):
|
||||
if mro[i].__module__.startswith('openerp.addons.base.'):
|
||||
self._founder = mro[i]
|
||||
break
|
||||
|
||||
def init(self, cr):
|
||||
'''
|
||||
Update existing iban accounts to comply to new regime
|
||||
@@ -104,7 +89,8 @@ class res_partner_bank(orm.Model):
|
||||
or vals.get('acc_number_domestic', False))
|
||||
vals['acc_number'], vals['acc_number_domestic'] = (
|
||||
self._correct_IBAN(iban))
|
||||
return self._founder.create(self, cr, uid, vals, context)
|
||||
return super(res_partner_bank, self).create(
|
||||
cr, uid, vals, context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
'''
|
||||
@@ -124,7 +110,8 @@ class res_partner_bank(orm.Model):
|
||||
self._correct_IBAN(account['acc_number']))
|
||||
else:
|
||||
vals['acc_number_domestic'] = False
|
||||
self._founder.write(self, cr, uid, account['id'], vals, context)
|
||||
super(res_partner_bank, self).write(
|
||||
cr, uid, account['id'], vals, context)
|
||||
return True
|
||||
|
||||
def onchange_acc_number(
|
||||
|
||||
Reference in New Issue
Block a user