From 4466370eb563fcb13bee227d898f7e3550ff8aa5 Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Mon, 12 Jun 2023 09:51:41 +0000 Subject: [PATCH] [FIX] l10n_ch: Swiss QRCode relax origin country constraint We allow creation of QR-Bill codes when they are issued from another country than Switzerland. Steps to reproduce : 1. Enable QRcode Bill in Accounting settings 2. Set a valid Swiss QR-IBAN account on your company. (Contact > CH Company > Accounting tab > Bank Accounts: Set account number to `CH21 3080 8001 2345 6782 7`.) 3. Set the CH Company's country to something else than Switzerland. 4. Create a Swiss partner (be sure to set all address/ZIP/city/country=CH). 5. Create an invoice to that Swiss partner and post it. 6. Click Print QR-BILL, it will raise an error. closes odoo/odoo#127798 Task: 3359821 X-original-commit: c456c78e347c707b0f5b684b47631e5566963289 Signed-off-by: Olivier Colson (oco) Signed-off-by: Claire Bretton (clbr) --- addons/l10n_ch/models/ir_actions_report.py | 2 -- addons/l10n_ch/models/res_bank.py | 2 -- addons/l10n_ch/tests/test_ch_qr_code.py | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/l10n_ch/models/ir_actions_report.py b/addons/l10n_ch/models/ir_actions_report.py index e550fe7adee..fa99cfe483c 100644 --- a/addons/l10n_ch/models/ir_actions_report.py +++ b/addons/l10n_ch/models/ir_actions_report.py @@ -38,8 +38,6 @@ class IrActionsReport(models.Model): # Determine which invoices need a QR. qr_inv_ids = [] for invoice in invoices: - if invoice.company_id.country_code != 'CH': - continue if invoice.l10n_ch_is_qr_valid: qr_inv_ids.append(invoice.id) # Render the additional reports. diff --git a/addons/l10n_ch/models/res_bank.py b/addons/l10n_ch/models/res_bank.py index 081996d8f5a..1b4f0c6fdf5 100644 --- a/addons/l10n_ch/models/res_bank.py +++ b/addons/l10n_ch/models/res_bank.py @@ -201,8 +201,6 @@ class ResPartnerBank(models.Model): error_messages = [_("The Swiss QR code could not be generated for the following reason(s):")] if self.acc_type != 'iban': error_messages.append(_("The account type isn't QR-IBAN or IBAN.")) - if self.partner_id.country_id.code != 'CH': - error_messages.append(_("Your company isn't located in Switzerland.")) if not debtor_partner or debtor_partner.country_id.code not in ('CH', 'LI'): error_messages.append(_("The debtor partner's address isn't located in Switzerland.")) if currency.id not in (self.env.ref('base.EUR').id, self.env.ref('base.CHF').id): diff --git a/addons/l10n_ch/tests/test_ch_qr_code.py b/addons/l10n_ch/tests/test_ch_qr_code.py index 08b5aa1e16b..c94738f0cb0 100644 --- a/addons/l10n_ch/tests/test_ch_qr_code.py +++ b/addons/l10n_ch/tests/test_ch_qr_code.py @@ -80,6 +80,10 @@ class TestSwissQRCode(AccountTestInvoicingCommon): # Assigning a QR reference should fix it self.ch_qr_invoice.payment_reference = '210000000003139471430009017' + # even if the invoice is not issued from Switzerland we want to generate the code + self.ch_qr_invoice.company_id.partner_id.country_id = self.env.ref('base.fr') + self.ch_qr_invoice._generate_qr_code() + def test_ch_qr_code_detection(self): """ Checks Swiss QR-code auto-detection when no specific QR-method is given to the invoice.