From de0c5f4b8cb3c2ee03657e190daba37cdfa151ff Mon Sep 17 00:00:00 2001 From: wan Date: Wed, 16 Dec 2020 11:05:29 +0000 Subject: [PATCH] [FIX] l10n_ch: _is_qr_iban without bank Part of task 2124952 Return False if the recordset is empty. ```python self.acc_type == 'iban' ``` This already ensures there is at most one record. We now have the same behavior as for `_is_isr_issuer` (False if empty recordset) Was needed after cb8b6db391405687bc871d36b4b53e0d7dca4016 because it is now calling _is_qr_iban on a possible empty recordset. Revert 1b2aef65f4ea29946f9710ba8012cf67ba59cd48 --- addons/l10n_ch/models/account_invoice.py | 5 +---- addons/l10n_ch/models/res_bank.py | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index f0c6eae22ff..d8650bd1e03 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -246,10 +246,7 @@ class AccountMove(models.Model): for inv in self: if inv.move_type == 'in_invoice' and inv.company_id.country_id.code == "CH": partner_bank = inv.partner_bank_id - if partner_bank: - needs_isr_ref = partner_bank._is_qr_iban() or partner_bank._is_isr_issuer() - else: - needs_isr_ref = False + needs_isr_ref = partner_bank._is_qr_iban() or partner_bank._is_isr_issuer() if needs_isr_ref and not inv._has_isr_ref(): inv.l10n_ch_isr_needs_fixing = True continue diff --git a/addons/l10n_ch/models/res_bank.py b/addons/l10n_ch/models/res_bank.py index 6011ce31f30..cd0e8c6a1ef 100644 --- a/addons/l10n_ch/models/res_bank.py +++ b/addons/l10n_ch/models/res_bank.py @@ -263,8 +263,6 @@ class ResPartnerBank(models.Model): QR-codes. They are formed like regular IBANs, but are actually something different. """ - self.ensure_one() - return self.acc_type == 'iban' \ and self._check_qr_iban_range(self.sanitized_acc_number)