From 818f3457219be405172acaec644434f725395f8a Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Thu, 23 Jul 2020 09:26:06 +0200 Subject: [PATCH] add extra check on bank account in init cycle --- account_ebics/models/ebics_userid.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/account_ebics/models/ebics_userid.py b/account_ebics/models/ebics_userid.py index 5d87c0b..4953474 100644 --- a/account_ebics/models/ebics_userid.py +++ b/account_ebics/models/ebics_userid.py @@ -240,6 +240,11 @@ class EbicsUserID(models.Model): bank, user, version=ebics_version) # Send the public electronic signature key to the bank. + ebics_config_bank = self.ebics_config_id.journal_ids[0].bank_id + if not ebics_config_bank: + raise UserError(_( + "No bank defined for the financial journal " + "of the EBICS Config")) try: supported_versions = client.HEV() if ebics_version not in supported_versions: @@ -288,8 +293,8 @@ class EbicsUserID(models.Model): self.ebics_config_id._update_order_number(OrderID) # Create an INI-letter which must be printed and sent to the bank. - bank = self.ebics_config_id.journal_ids[0].bank_id - cc = bank.country.code + ebics_config_bank = self.ebics_config_id.journal_ids[0].bank_id + cc = ebics_config_bank.country.code if cc in ['FR', 'DE']: lang = cc else: @@ -304,7 +309,7 @@ class EbicsUserID(models.Model): [self.ebics_config_id.ebics_host, 'ini_letter', fn_date]) + '.pdf' full_tmp_fn = os.path.normpath(tmp_dir + '/' + fn) user.create_ini_letter( - bankname=bank.name, + bankname=ebics_config_bank.name, path=full_tmp_fn, lang=lang) with open(full_tmp_fn, 'rb') as f: