Skip to content

Commit

Permalink
[FIX] sale_payment_sheet: Post-install test + 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 1593a90 commit d6e9a00
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sale_payment_sheet/tests/test_sale_payment_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
from freezegun import freeze_time

from odoo.exceptions import UserError, ValidationError
from odoo.tests import Form, TransactionCase
from odoo.tests import Form, TransactionCase, tagged


@freeze_time("2021-01-01 09:30:00")
@tagged("post_install", "-at_install")
class TestSaleInvoicePayment(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
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)
if not coa:
# Load the first available CoA
coa = cls.env["account.chart.template"].search(
[("visible", "=", True)], limit=1
)
coa.try_loading(company=cls.env.company, install_demo=False)
# Remove time zone from user to avoid to time local representation
cls.env.user.partner_id.tz = False
# Archive all reconciliation models to avoid them interfering with the tests
Expand Down

0 comments on commit d6e9a00

Please sign in to comment.