From fdbfb332b528ba8b35d7529eecd610086465aff8 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 24 Feb 2021 17:41:28 +0000 Subject: [FIX] l10n_ch: human readable ISR number set to False The condition on computation of `l10n_ch_isr_number_spaced` was not in line anymore with `l10n_ch_isr_number` computation. With fixes on the ISR number the use of `l10n_ch_isr_postal` is rightly not mandatory anymore. This lead to an empty field, visible on the ISR report. closes odoo/odoo#66921 X-original-commit: fcc06f7dd1a28949389ca2fdefb59c2fbe978c4a Signed-off-by: Josse Colpaert --- addons/l10n_ch/models/account_invoice.py | 2 +- addons/l10n_ch/tests/test_gen_isr_reference.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'addons') diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index f0c6eae22ff..6354167c6d9 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -150,7 +150,7 @@ class AccountMove(models.Model): return res for record in self: - if record.name and record.partner_bank_id and record.partner_bank_id.l10n_ch_postal: + if record.l10n_ch_isr_number: record.l10n_ch_isr_number_spaced = _space_isr_number(record.l10n_ch_isr_number) else: record.l10n_ch_isr_number_spaced = False diff --git a/addons/l10n_ch/tests/test_gen_isr_reference.py b/addons/l10n_ch/tests/test_gen_isr_reference.py index 6d8a75dd083..0ee498f4dc0 100644 --- a/addons/l10n_ch/tests/test_gen_isr_reference.py +++ b/addons/l10n_ch/tests/test_gen_isr_reference.py @@ -44,8 +44,10 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.name = "INV/01234567890" expected_isr = "000000000000000012345678903" + expected_isr_spaced = "00 00000 00000 00001 23456 78903" expected_optical_line = "0100001307807>000000000000000012345678903+ 010001628>" self.assertEqual(self.invoice.l10n_ch_isr_number, expected_isr) + self.assertEqual(self.invoice.l10n_ch_isr_number_spaced, expected_isr_spaced) self.assertEqual(self.invoice.l10n_ch_isr_optical_line, expected_optical_line) def test_qrr(self): @@ -54,7 +56,9 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.name = "INV/01234567890" expected_isr = "000000000000000012345678903" + expected_isr_spaced = "00 00000 00000 00001 23456 78903" self.assertEqual(self.invoice.l10n_ch_isr_number, expected_isr) + self.assertEqual(self.invoice.l10n_ch_isr_number_spaced, expected_isr_spaced) # No need to check optical line, we have no use for it with QR-bill def test_isr_long_reference(self): @@ -63,8 +67,10 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.name = "INV/123456789012345678901234567890" expected_isr = "567890123456789012345678901" + expected_isr_spaced = "56 78901 23456 78901 23456 78901" expected_optical_line = "0100001307807>567890123456789012345678901+ 010001628>" self.assertEqual(self.invoice.l10n_ch_isr_number, expected_isr) + self.assertEqual(self.invoice.l10n_ch_isr_number_spaced, expected_isr_spaced) self.assertEqual(self.invoice.l10n_ch_isr_optical_line, expected_optical_line) def test_missing_isr_subscription_num(self): @@ -73,6 +79,7 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.partner_bank_id = self.bank_acc_isr self.assertFalse(self.invoice.l10n_ch_isr_number) + self.assertFalse(self.invoice.l10n_ch_isr_number_spaced) self.assertFalse(self.invoice.l10n_ch_isr_optical_line) def test_missing_isr_subscription_num_in_wrong_field(self): @@ -82,12 +89,14 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.partner_bank_id = self.bank_acc_isr self.assertFalse(self.invoice.l10n_ch_isr_number) + self.assertFalse(self.invoice.l10n_ch_isr_number_spaced) self.assertFalse(self.invoice.l10n_ch_isr_optical_line) def test_no_bank_account(self): self.invoice.partner_bank_id = False self.assertFalse(self.invoice.l10n_ch_isr_number) + self.assertFalse(self.invoice.l10n_ch_isr_number_spaced) self.assertFalse(self.invoice.l10n_ch_isr_optical_line) def test_wrong_currency(self): @@ -95,4 +104,5 @@ class TestGenISRReference(AccountTestInvoicingCommon): self.invoice.currency_id = self.env.ref("base.BTN") self.assertFalse(self.invoice.l10n_ch_isr_number) + self.assertFalse(self.invoice.l10n_ch_isr_number_spaced) self.assertFalse(self.invoice.l10n_ch_isr_optical_line) -- cgit v1.2.3