Skip to content

Commit

Permalink
[FIX] account_netting: Fallback to load CoA
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
victoralmau committed Feb 25, 2025
1 parent 6d23ee2 commit c9c0883
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions account_netting/tests/test_account_netting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ class TestAccountNetting(common.TransactionCase):
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
if not cls.env.company.chart_template_id:
# Load a CoA if there's none in current company
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)

Check warning on line 21 in account_netting/tests/test_account_netting.py

View check run for this annotation

Codecov / codecov/patch

account_netting/tests/test_account_netting.py#L21

Added line #L21 was not covered by tests
if not coa:
# Load the first available CoA
coa = cls.env["account.chart.template"].search(

Check warning on line 24 in account_netting/tests/test_account_netting.py

View check run for this annotation

Codecov / codecov/patch

account_netting/tests/test_account_netting.py#L24

Added line #L24 was not covered by tests
[("visible", "=", True)], limit=1
)
coa.try_loading(company=cls.env.company, install_demo=False)

Check warning on line 27 in account_netting/tests/test_account_netting.py

View check run for this annotation

Codecov / codecov/patch

account_netting/tests/test_account_netting.py#L27

Added line #L27 was not covered by tests
res_users_account_manager = cls.env.ref("account.group_account_manager")
partner_manager = cls.env.ref("base.group_partner_manager")
cls.env.user.write(
Expand Down

0 comments on commit c9c0883

Please sign in to comment.