[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>
This commit is contained in:
Yannick Vaucher
2020-06-23 10:17:26 +00:00
committed by oco-odoo
parent 8a1e1c0c4c
commit 2e9aac7655
2 changed files with 11 additions and 13 deletions
-2
View File
@@ -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):
+11 -11
View File
@@ -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)