[FIX] base, account: allow AllL10n test case to start
Since a5b6f31, an attribute allowed_company_ids is set on request when
calling the module button_immediate_install method.
This method is called during the test TestAllL10n which does not have a
bound request and makes it fail.
With this commit, the attribute is set only if request is bound.
By the way, a small improvement is added in the test.
Before this commit, when the test was failing because of the
button_immediate_install, it was immediately stopped.
The same problem was arising during the test method, it was stopped at
the first failure.
As this test is run as a nightly test, one have to wait the next day to
discover the next problem.
With this commit, the exceptions are catched during the l10n_ modules
installation and a simple error line is written in the logs. That way,
the runbot will still detect the error.
Also, the main test method that installs all the chart of accounts
splits those install into subtests. This prevent the method to stop at
first failure.
closes odoo/odoo#33654
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
This commit is contained in:
@@ -27,7 +27,10 @@ class TestAllL10n(SingleTransactionCase):
|
||||
_logger.info("Modules to install: %s" % [x.name for x in l10n_mods])
|
||||
for mod in l10n_mods:
|
||||
_logger.info('Installing l10n module %s' % mod.name)
|
||||
mod.button_immediate_install()
|
||||
try:
|
||||
mod.button_immediate_install()
|
||||
except Exception:
|
||||
_logger.error('Failure during installation of module "%s"', mod.name)
|
||||
# Now that new modules are installed, we have to reset the environment
|
||||
api.Environment.reset()
|
||||
cls.env = api.Environment(cls.cr, odoo.SUPERUSER_ID, {})
|
||||
@@ -36,9 +39,13 @@ class TestAllL10n(SingleTransactionCase):
|
||||
coas = self.env['account.chart.template'].search([])
|
||||
for coa in coas:
|
||||
cname = 'company_%s' % str(coa.id)
|
||||
_logger.info('Testing COA: %s (company: %s)' % (coa.name, cname))
|
||||
comp = self.env['res.company'].create({
|
||||
'name': cname,
|
||||
})
|
||||
self.env.company_id = comp
|
||||
coa.try_loading_for_current_company()
|
||||
self.env.user.company_ids += comp
|
||||
self.env.user.company_id = comp
|
||||
msg = 'Testing COA: %s (company: %s)' % (coa.name, cname)
|
||||
_logger.info(msg)
|
||||
with self.subTest(msg=msg):
|
||||
with self.cr.savepoint():
|
||||
coa.try_loading_for_current_company()
|
||||
|
||||
@@ -445,7 +445,8 @@ class Module(models.Model):
|
||||
# allowed companies to configure it on the correct company.
|
||||
# Otherwise, the SUPERUSER won't be aware of that and will try to
|
||||
# configure the CoA on his own company, which makes no sense.
|
||||
request.allowed_company_ids = self.env.company_ids.ids
|
||||
if request:
|
||||
request.allowed_company_ids = self.env.company_ids.ids
|
||||
return self._button_immediate_function(type(self).button_install)
|
||||
|
||||
@assert_log_admin_access
|
||||
|
||||
Reference in New Issue
Block a user