[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) <oco@odoo.com>
Signed-off-by: Claire Bretton (clbr) <clbr@odoo.com>
This commit is contained in:
Claire Bretton (clbr)
2023-07-11 12:00:35 +02:00
parent 17cd7fcd6d
commit 4466370eb5
3 changed files with 4 additions and 4 deletions
@@ -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.
-2
View File
@@ -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):
+4
View File
@@ -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.