test_account_all_l10n.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # -*- coding: utf-8 -*-
  2. import logging
  3. from odoo.tests import standalone
  4. _logger = logging.getLogger(__name__)
  5. @standalone('all_l10n')
  6. def test_all_l10n(env):
  7. """ This test will install all the l10n_* modules.
  8. As the module install is not yet fully transactional, the modules will
  9. remain installed after the test.
  10. """
  11. assert env.ref('base.module_account').demo, "Need the demo to test with data"
  12. l10n_mods = env['ir.module.module'].search([
  13. ('name', 'like', 'l10n%'),
  14. ('state', '=', 'uninstalled'),
  15. ])
  16. l10n_mods.button_immediate_install()
  17. env.reset() # clear the set of environments
  18. env = env() # get an environment that refers to the new registry
  19. coas = env['account.chart.template'].search([
  20. ('id', 'not in', env['res.company'].search([]).chart_template_id.ids)
  21. ])
  22. for coa in coas:
  23. cname = 'company_%s' % str(coa.id)
  24. company = env['res.company'].create({
  25. 'name': cname,
  26. 'country_id': coa.country_id.id,
  27. })
  28. env.user.company_ids += company
  29. env.user.company_id = company
  30. _logger.info('Testing COA: %s (company: %s)' % (coa.name, cname))
  31. try:
  32. with env.cr.savepoint():
  33. coa.try_loading()
  34. except Exception:
  35. _logger.error("Error when creating COA %s", coa.name, exc_info=True)