Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FIX] base_bank_from_iban: Handle correctly non IBAN accounts #213

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

pedrobaeza
Copy link
Member

@pedrobaeza pedrobaeza commented Nov 7, 2024

Forward-port of #206 and #212

If any non IBAN account is provided, there's an ugly log with traceback each time, polluting tests and system logs:

INFO prod odoo.addons.base_bank_from_iban.models.res_partner_bank: Could not find bank from IBAN
Traceback (most recent call last):
  File ".../addons/base_bank_from_iban/models/res_partner_bank.py", line 34, in _add_bank_vals
    bank = self._get_bank_from_iban(vals["acc_number"])
  File ".../addons/base_bank_from_iban/models/res_partner_bank.py", line 42, in _get_bank_from_iban
    iban = schwifty.IBAN(acc_number)
  File ".../python/site-packages/schwifty/iban.py", line 77, in __init__
    self.validate(validate_bban)
  File ".../python/site-packages/schwifty/iban.py", line 175, in validate
    self._validate_characters()
  File ".../python/site-packages/schwifty/iban.py", line 185, in _validate_characters
    raise exceptions.InvalidStructure(f"Invalid characters in IBAN {self!s}")
schwifty.exceptions.InvalidStructure: Invalid characters in IBAN XXXXXX

This commit removes that traceback catching the proper exception, and handling it accordingly, and also removing an extra INFO log that was not adding value.

@Tecnativa

If any non IBAN account is provided, there's an ugly log with traceback
each time, polluting tests and system logs:

```
INFO prod odoo.addons.base_bank_from_iban.models.res_partner_bank: Could not find bank from IBAN
Traceback (most recent call last):
  File ".../addons/base_bank_from_iban/models/res_partner_bank.py", line 34, in _add_bank_vals
    bank = self._get_bank_from_iban(vals["acc_number"])
  File ".../addons/base_bank_from_iban/models/res_partner_bank.py", line 42, in _get_bank_from_iban
    iban = schwifty.IBAN(acc_number)
  File ".../python/site-packages/schwifty/iban.py", line 77, in __init__
    self.validate(validate_bban)
  File ".../python/site-packages/schwifty/iban.py", line 175, in validate
    self._validate_characters()
  File ".../python/site-packages/schwifty/iban.py", line 185, in _validate_characters
    raise exceptions.InvalidStructure(f"Invalid characters in IBAN {self!s}")
schwifty.exceptions.InvalidStructure: Invalid characters in IBAN XXXXXX
```

This commit removes that traceback catching the proper exception, and
handling it accordingly, and also removing an extra INFO log that was
not adding value.
@pedrobaeza pedrobaeza added this to the 17.0 milestone Nov 7, 2024
@pedrobaeza
Copy link
Member Author

Let's finish the chain:

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 17.0-ocabot-merge-pr-213-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 68f08f0 into OCA:17.0 Nov 7, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 0435437. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants