mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] account_banking_sepa_direct_debit: Fix tests due to upstream change
Odoo has added a constraint for avoiding a company currency change if there are move lines, making these tests to fail, as the currency is changed to EUR. With this commit, we create a new company with EUR currency for avoiding the problem. This commit also changes account_banking_mandate for not duplicating mandate number, as it was detected during the test creation. Similar to 1f8e345
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2018 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.addons.account.tests.account_test_classes\
|
||||
import AccountingTestCase
|
||||
from odoo.tests import common
|
||||
from odoo.tools import float_compare
|
||||
import time
|
||||
from lxml import etree
|
||||
|
||||
|
||||
class TestSDD(AccountingTestCase):
|
||||
class TestSDD(common.HttpCase):
|
||||
at_install = False
|
||||
post_install = True
|
||||
|
||||
def setUp(self):
|
||||
super(TestSDD, self).setUp()
|
||||
@@ -25,37 +27,61 @@ class TestSDD(AccountingTestCase):
|
||||
self.attachment_model = self.env['ir.attachment']
|
||||
self.invoice_model = self.env['account.invoice']
|
||||
self.invoice_line_model = self.env['account.invoice.line']
|
||||
company = self.env.ref('base.main_company')
|
||||
self.eur_currency = self.env.ref('base.EUR')
|
||||
self.main_company = self.env['res.company'].create({
|
||||
'name': 'Test EUR company',
|
||||
'currency_id': self.eur_currency.id,
|
||||
'sepa_creditor_identifier': 'FR78ZZZ424242',
|
||||
})
|
||||
self.env.user.write({
|
||||
'company_ids': [(6, 0, self.main_company.ids)],
|
||||
'company_id': self.main_company.id,
|
||||
})
|
||||
self.env.ref(
|
||||
'l10n_generic_coa.configurable_chart_template'
|
||||
).try_loading_for_current_company()
|
||||
self.partner_agrolait = self.env.ref('base.res_partner_2')
|
||||
self.partner_c2c = self.env.ref('base.res_partner_12')
|
||||
self.account_revenue = self.account_model.search([(
|
||||
'user_type_id',
|
||||
'=',
|
||||
self.env.ref('account.data_account_type_revenue').id)], limit=1)
|
||||
self.account_receivable = self.account_model.search([(
|
||||
'user_type_id',
|
||||
'=',
|
||||
self.env.ref('account.data_account_type_receivable').id)], limit=1)
|
||||
self.partner_agrolait.company_id = self.main_company.id
|
||||
self.partner_c2c.company_id = self.main_company.id
|
||||
self.account_revenue = self.account_model.search([
|
||||
('user_type_id', '=',
|
||||
self.env.ref(
|
||||
'account.data_account_type_revenue').id),
|
||||
('company_id', '=', self.main_company.id),
|
||||
], limit=1)
|
||||
self.account_receivable = self.account_model.search([
|
||||
('user_type_id', '=',
|
||||
self.env.ref('account.data_account_type_receivable').id),
|
||||
('company_id', '=', self.main_company.id),
|
||||
], limit=1)
|
||||
self.company_bank = self.env.ref(
|
||||
'account_payment_mode.main_company_iban'
|
||||
).copy({
|
||||
'company_id': self.main_company.id,
|
||||
'partner_id': self.main_company.partner_id.id,
|
||||
'bank_id': (
|
||||
self.env.ref('account_payment_mode.bank_la_banque_postale').id
|
||||
),
|
||||
})
|
||||
# create journal
|
||||
self.bank_journal = self.journal_model.create({
|
||||
'name': 'Company Bank journal',
|
||||
'type': 'bank',
|
||||
'code': 'BNKFC',
|
||||
'bank_account_id':
|
||||
self.env.ref('account_payment_mode.main_company_iban').id,
|
||||
'bank_id':
|
||||
self.env.ref('account_payment_mode.bank_la_banque_postale').id,
|
||||
})
|
||||
'bank_account_id': self.company_bank.id,
|
||||
'bank_id': self.company_bank.bank_id.id,
|
||||
})
|
||||
# update payment mode
|
||||
self.payment_mode = self.env.ref(
|
||||
'account_banking_sepa_direct_debit.'
|
||||
'payment_mode_inbound_sepa_dd1')
|
||||
'account_banking_sepa_direct_debit.payment_mode_inbound_sepa_dd1'
|
||||
).copy({
|
||||
'company_id': self.main_company.id,
|
||||
})
|
||||
self.payment_mode.write({
|
||||
'bank_account_link': 'fixed',
|
||||
'fixed_journal_id': self.bank_journal.id,
|
||||
})
|
||||
self.eur_currency_id = self.env.ref('base.EUR').id
|
||||
company.currency_id = self.eur_currency_id
|
||||
})
|
||||
# Trigger the recompute of account type on res.partner.bank
|
||||
for bank_acc in self.partner_bank_model.search([]):
|
||||
bank_acc.acc_number = bank_acc.acc_number
|
||||
@@ -88,7 +114,7 @@ class TestSDD(AccountingTestCase):
|
||||
agrolait_pay_line1 = pay_lines[0]
|
||||
accpre = self.env['decimal.precision'].precision_get('Account')
|
||||
self.assertEquals(
|
||||
agrolait_pay_line1.currency_id.id, self.eur_currency_id)
|
||||
agrolait_pay_line1.currency_id, self.eur_currency)
|
||||
self.assertEquals(
|
||||
agrolait_pay_line1.mandate_id, invoice1.mandate_id)
|
||||
self.assertEquals(
|
||||
@@ -108,7 +134,7 @@ class TestSDD(AccountingTestCase):
|
||||
self.assertEquals(len(bank_lines), 1)
|
||||
agrolait_bank_line = bank_lines[0]
|
||||
self.assertEquals(
|
||||
agrolait_bank_line.currency_id.id, self.eur_currency_id)
|
||||
agrolait_bank_line.currency_id, self.eur_currency)
|
||||
self.assertEquals(float_compare(
|
||||
agrolait_bank_line.amount_currency, 42.0, precision_digits=accpre),
|
||||
0)
|
||||
|
||||
Reference in New Issue
Block a user