From 9b3c19b41e4cfc0d892fa8b03ff13d71efdee780 Mon Sep 17 00:00:00 2001 From: wan Date: Thu, 4 Mar 2021 13:21:14 +0000 Subject: [PATCH] [FIX] account: fix standalone test with demo data creation The test is running in sudo mode, so we need to specify the company in the search. Also do not load the demo data when installing as we would do the work twice for most localization. closes odoo/odoo#67235 Signed-off-by: Laurent Smet --- addons/account/demo/account_demo.py | 5 ++++- addons/account/tests/test_account_all_l10n.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/demo/account_demo.py b/addons/account/demo/account_demo.py index 1b91f45b954..11c5d116d3d 100644 --- a/addons/account/demo/account_demo.py +++ b/addons/account/demo/account_demo.py @@ -106,7 +106,10 @@ class AccountChartTemplate(models.Model): ref = self.env.ref return ('account.bank.statement', { f'{cid}_demo_bank_statement_1': { - 'journal_id': self.env['account.journal'].search([('type', '=', 'bank')], limit=1).id, + 'journal_id': self.env['account.journal'].search([ + ('type', '=', 'bank'), + ('company_id', '=', cid), + ], limit=1).id, 'date': time.strftime('%Y')+'-01-01', 'balance_end_real': 9944.87, 'balance_start': 5103.0, diff --git a/addons/account/tests/test_account_all_l10n.py b/addons/account/tests/test_account_all_l10n.py index fbf9887bdd1..20caf49de64 100644 --- a/addons/account/tests/test_account_all_l10n.py +++ b/addons/account/tests/test_account_all_l10n.py @@ -13,6 +13,8 @@ def test_all_l10n(env): As the module install is not yet fully transactional, the modules will remain installed after the test. """ + # Do not install the demo data while installing the modules + env.ref('base.module_account').demo = False l10n_mods = env['ir.module.module'].search([ ('name', 'like', 'l10n%'), ('state', '=', 'uninstalled'), @@ -21,6 +23,8 @@ def test_all_l10n(env): env.reset() # clear the set of environments env = env() # get an environment that refers to the new registry + # Install the demo data when testing + env.ref('base.module_account').demo = True coas = env['account.chart.template'].search([]) for coa in coas: cname = 'company_%s' % str(coa.id)