summaryrefslogtreecommitdiff
path: root/addons/l10n_ch
diff options
context:
space:
mode:
authorYannick Vaucher <yannick.vaucher@camptocamp.com>2020-05-20 20:09:51 +0000
committeroco-odoo <oco@odoo.com>2020-06-23 10:17:26 +0000
commit2e9aac765536f30748d69cdd06eee2164983f853 (patch)
tree5a78af2b8e1fc3f7f17ddb60a265b19d854f2c4a /addons/l10n_ch
parent8a1e1c0c4cac3034bf6caada0004680942b04703 (diff)
[FIX] l10n_ch - print ISR tests
resolves the following error: E psycopg2.IntegrityError: null value in column "partner_id" violates not-null constraint E DETAIL: Failing row contains (193, 010391391, null, null, null, null, 10, null, 1, 1, 2020-05-20 20:05:28.431208, 1, 2020-05-20 20:05:28.431208, null, null, null, null). To generate an ISR payment slip you need: * a type == out_invoice * a partner bank account with a ISR issuer number (field l10n_ch_isr_subscription_[chf|eur]) * a currency either in EUR or CHF Remarks: * l10n_ch_postal is not necessary and must be used for Vendors only. * human readable subscription number is xx-yyyyyy-c validation of such format is done with the following PR: https://github.com/odoo/odoo/pull/51544/files It does: - Removes unexisting field from tests - Adds required field on partner_id - Fix test with an actual case that case generate ISR payment slips closes odoo/odoo#53498 X-original-commit: 776fd59909d12c981585fac82cfa9f3603d96ccf Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/l10n_ch')
-rw-r--r--addons/l10n_ch/models/account_invoice.py2
-rw-r--r--addons/l10n_ch/tests/test_l10n_ch_isr.py22
2 files changed, 11 insertions, 13 deletions
diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py
index b0ff383c01a..5799f41384f 100644
--- a/addons/l10n_ch/models/account_invoice.py
+++ b/addons/l10n_ch/models/account_invoice.py
@@ -142,7 +142,6 @@ class AccountMove(models.Model):
@api.depends(
'move_type', 'name', 'currency_id.name',
- 'partner_bank_id.l10n_ch_postal',
'partner_bank_id.l10n_ch_isr_subscription_eur',
'partner_bank_id.l10n_ch_isr_subscription_chf')
def _compute_l10n_ch_isr_valid(self):
@@ -151,7 +150,6 @@ class AccountMove(models.Model):
record.l10n_ch_isr_valid = record.move_type == 'out_invoice' and\
record.name and \
record.l10n_ch_isr_subscription and \
- record.partner_bank_id.l10n_ch_postal and \
record.l10n_ch_currency_name in ['EUR', 'CHF']
def split_total_amount(self):
diff --git a/addons/l10n_ch/tests/test_l10n_ch_isr.py b/addons/l10n_ch/tests/test_l10n_ch_isr.py
index 1316613313e..541a2d7e0e5 100644
--- a/addons/l10n_ch/tests/test_l10n_ch_isr.py
+++ b/addons/l10n_ch/tests/test_l10n_ch_isr.py
@@ -34,6 +34,15 @@ class ISRTest(AccountTestCommon):
""" Generates a test res.partner.bank. """
return self.env['res.partner.bank'].create({
'acc_number': number,
+ 'partner_id': self.env.ref("base.res_partner_2").id,
+ })
+
+ def create_isr_issuer_account(self, number):
+ """ Generates a test res.partner.bank on company """
+ return self.env['res.partner.bank'].create({
+ 'acc_number': "ISR {} number",
+ 'partner_id': self.env.user.company_id.partner_id.id,
+ 'l10n_ch_isr_subscription_chf': number,
})
def print_isr(self, invoice):
@@ -79,18 +88,9 @@ class ISRTest(AccountTestCommon):
invoice_1 = self.create_invoice('base.CHF')
self.isr_not_generated(invoice_1)
- #Now we add an account for payment to our invoice, but still cannot generate the ISR
- test_account = self.create_account('250097798')
+ #Now we add an account for payment to our invoice, the ISR can be generated
+ test_account = self.create_isr_issuer_account('01-39139-1')
invoice_1.partner_bank_id = test_account
- self.isr_not_generated(invoice_1)
-
- #Finally, we add bank coordinates to our account. The ISR should now be available to generate
- test_bank = self.env['res.bank'].create({
- 'name':'Money Drop',
- 'l10n_ch_postal_chf':'010391391'
- })
-
- test_account.bank_id = test_bank
self.isr_generated(invoice_1)
#Now, let us show that, with the same data, an invoice in euros does not generate any ISR (because the bank does not have any EUR postal reference)