Skip to content

Commit 6b04aab

Browse files
committed
[FIX] account_move_template: Post-install test + fallback to load CoA
Since odoo/odoo@d0342c8, the default existing company is not getting a CoA automatically, provoking than the current tests fail with the error: odoo.exceptions.UserError: No journal could be found in company My Company (San Francisco) for any of those types: sale Thus, we put tests post-install for being sure localization modules are installed, the same as AccountTestInvoicingCommon does, but we don't inherit from it, as it creates an overhead creating 2 new companies and loading their CoA and some more stuff, while we don't need all of that. Besides, if you don't have `l10n_generic_coa` installed, you can't use another CoA (like `l10n_es`) easily, so we put little code to select the first available CoA.
1 parent 37a7683 commit 6b04aab

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

account_move_template/tests/test_account_move_template_options.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
33
from odoo import Command
44
from odoo.exceptions import UserError, ValidationError
5-
from odoo.tests.common import Form, TransactionCase
5+
from odoo.tests.common import Form, TransactionCase, tagged
66

77

8+
@tagged("-at_install", "post_install")
89
class TestAccountMoveTemplateEnhanced(TransactionCase):
910
@classmethod
1011
def setUpClass(cls):
1112
super().setUpClass()
13+
if not cls.env.company.chart_template_id:
14+
# Load a CoA if there's none in current company
15+
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)
16+
if not coa:
17+
# Load the first available CoA
18+
coa = cls.env["account.chart.template"].search(
19+
[("visible", "=", True)], limit=1
20+
)
21+
coa.try_loading(company=cls.env.company, install_demo=False)
1222
cls.Move = cls.env["account.move"]
1323
cls.Journal = cls.env["account.journal"]
1424
cls.Account = cls.env["account.account"]

0 commit comments

Comments
 (0)