diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index b40343a8e..e0384aea3 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -553,8 +553,6 @@ class account_bank_statement_line(orm.Model): 'currency': _get_currency, } -account_bank_statement_line() - class invoice(orm.Model): ''' diff --git a/account_banking/res_partner_bank.py b/account_banking/res_partner_bank.py index 513489cc1..6dabe1ac4 100644 --- a/account_banking/res_partner_bank.py +++ b/account_banking/res_partner_bank.py @@ -63,14 +63,11 @@ class ResPartnerBank(orm.Model): result = [('id', 'in', ids)] if 'acc_number_domestic' in self._columns: - # Some countries can't convert to BBAN - try: - bban = iban.localized_BBAN - # Prevent empty search filters - if bban: - extra_terms.append(('acc_number_domestic', term[1], bban)) - except: - pass + bban = iban.localized_BBAN + # Prevent empty search filters + if bban: + extra_terms.append( + ('acc_number_domestic', term[1], bban)) for extra_term in extra_terms: result = ['|'] + result + [extra_term] return result diff --git a/account_banking/sepa/iban.py b/account_banking/sepa/iban.py index 25993dd70..ece173404 100644 --- a/account_banking/sepa/iban.py +++ b/account_banking/sepa/iban.py @@ -408,10 +408,9 @@ class IBAN(str): Localized format of local or Basic Bank Account Number, aka BBAN ''' if self.countrycode == 'TR': - raise NotImplementedError, ( - 'The Turkish BBAN requires information that is not in the ' - 'IBAN number.' - ) + # The Turkish BBAN requires information that is not in the + # IBAN number. + return False return self.BBAN_format.BBAN(self) @property diff --git a/account_banking_iban_lookup/model/res_partner_bank.py b/account_banking_iban_lookup/model/res_partner_bank.py index d384a8e38..004a01761 100644 --- a/account_banking_iban_lookup/model/res_partner_bank.py +++ b/account_banking_iban_lookup/model/res_partner_bank.py @@ -194,33 +194,32 @@ class res_partner_bank(orm.Model): cr, uid, country_ids[0], context=context) values['country_id'] = country_ids[0] if country and country.code in sepa.IBAN.countries: - try: - info = online.account_info(country.code, acc_number) - if info: - iban_acc = sepa.IBAN(info.iban) - if iban_acc.valid: - values['acc_number_domestic'] = iban_acc.localized_BBAN - values['acc_number'] = unicode(iban_acc) - values['state'] = 'iban' - bank_id, country_id = get_or_create_bank( - self.pool, cr, uid, - info.bic or iban_acc.BIC_searchkey, - name = info.bank - ) - if country_id: - values['country_id'] = country_id - values['bank'] = bank_id or False - if info.bic: - values['bank_bic'] = info.bic - else: - info = None - if info is None: - result.update(warning( - _('Invalid data'), - _('The account number appears to be invalid for %s') - % country.name - )) - except NotImplementedError: + info = online.account_info(country.code, acc_number) + if info: + iban_acc = sepa.IBAN(info.iban) + if iban_acc.valid: + values['acc_number_domestic'] = iban_acc.localized_BBAN + values['acc_number'] = unicode(iban_acc) + values['state'] = 'iban' + bank_id, country_id = get_or_create_bank( + self.pool, cr, uid, + info.bic or iban_acc.BIC_searchkey, + name = info.bank + ) + if country_id: + values['country_id'] = country_id + values['bank'] = bank_id or False + if info.bic: + values['bank_bic'] = info.bic + else: + info = None + if info is None: + result.update(warning( + _('Invalid data'), + _('The account number appears to be invalid for %s') + % country.name + )) + if info is False: if country.code in sepa.IBAN.countries: acc_number_fmt = sepa.BBAN(acc_number, country.code) if acc_number_fmt.valid: diff --git a/account_banking_iban_lookup/online.py b/account_banking_iban_lookup/online.py index 96583ede7..48036ce46 100644 --- a/account_banking_iban_lookup/online.py +++ b/account_banking_iban_lookup/online.py @@ -157,13 +157,13 @@ def account_info(iso, bank_acc): ''' Consult the online database for this country to obtain its corresponding IBAN/BIC number and other info available. - Raise NotImplemented when no information service could be found. Returns None when a service was found but something went wrong. - Returns a dictionary (struct) of information when found. + Returns a dictionary (struct) of information when found, or + False when not implemented. ''' if iso in _account_info: return _account_info[iso](bank_acc) - raise NotImplementedError() + return False bic_re = re.compile("[^']+'([^']*)'.*") SWIFTlink = 'http://www.swift.com/bsl/freequery.do'