[FIX] l10n_*: fix tests + don't decorate test class with freeze_time

*: l10n_fr_fec, l10n_account_edi_ubl_cii_tests

Fix two failing tests in: - l10n_fr_fec: Add missing factor_percent in
the creation of a tax in the test for FEC - account_edi_ubl_cii: The
invoice name supposed the old convention per month while this was
changed to on a per year basis anyways for customer invoices.

These two tests were ignored by runbot for a while and began to fail
only after the runbot exception was removed (see:
https://runbot.odoo.com/runbot/build/22172258).

In addition, tests in `TestItEdi` started to fail as well when the
exception was removed ! In particular, if an exception was raised in the
`setUpClass` of `TestAccountFrFec`, the tests in `TestItEdi` were
failing.

This is because `TestAccountFrFec` is decorated with
`freeze_time('2021-05-02')`. Indeed, when one decorates a subclass of
`unittest.TestCase` with freeze_time, if the `setUpClass` raises an
Exception, `_freeze_time.stop()` is not called, and the frozen date is
propagated in the other test classes. As a consequence, when an
exception was raised in the `setUpClass` of `TestAccountFrFec`, the
freeze_time set in `TestAccountFrFec` (2021-05-02) was kept in
`TestItEdi`, thus causing tests to fail in `TestItEdi`.

As a conclusion, `freeze_time` should never decorate an Odoo test class.

closes odoo/odoo#109324

X-original-commit: 531270666ec5a6582d4a0a68ea534f2a3a6852ff
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Josse Colpaert
2023-01-06 18:41:38 +01:00
committed by Julien Van Roy
parent 44ce99ec9a
commit ec172b74fe
+12 -10
View File
@@ -10,7 +10,6 @@ from odoo.tests import tagged
from odoo import fields, Command
@freeze_time('2021-05-02')
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestAccountFrFec(AccountTestInvoicingCommon):
@@ -22,7 +21,16 @@ class TestAccountFrFec(AccountTestInvoicingCommon):
company.vat = 'FR13542107651'
lines_data = [(1437.12, 'Hello\tDarkness'), (1676.64, 'my\rold\nfriend'), (3353.28, '\t\t\r')]
today = fields.Date.today().strftime('%Y-%m-%d')
with freeze_time('2021-05-02'):
today = fields.Date.today().strftime('%Y-%m-%d')
cls.wizard = cls.env['account.fr.fec'].create({
'date_from': fields.Date.today() - timedelta(days=1),
'date_to': fields.Date.today(),
'export_type': 'official',
'test_file': True,
})
cls.tax_sale_a = cls.env['account.tax'].create({
'name': "TVA 20,0%",
@@ -31,11 +39,12 @@ class TestAccountFrFec(AccountTestInvoicingCommon):
'amount': 20,
'invoice_repartition_line_ids': [
Command.create({
'factor_percent': 100.0,
'repartition_type': 'base',
}),
Command.create({
'repartition_type': 'tax',
'factor': 100,
'factor_percent': 100.0,
'account_id': cls.env['account.account'].search([('code', '=', "445710")], limit=1).id,
})
]
@@ -57,13 +66,6 @@ class TestAccountFrFec(AccountTestInvoicingCommon):
})
cls.invoice_a.action_post()
cls.wizard = cls.env['account.fr.fec'].create({
'date_from': fields.Date.today() - timedelta(days=1),
'date_to': fields.Date.today(),
'export_type': 'official',
'test_file': True,
})
def test_generate_fec_sanitize_pieceref(self):
self.wizard.generate_fec()
expected_content = (