Skip to content

Commit

Permalink
[tests] Avoid crash out of the CI when no accounting is setup
Browse files Browse the repository at this point in the history
For the moment, commown_contract_forecast does not depend on any accounting setup
module, so the tests that generate invoices crashes. This commit fixes that by
inserting odoo-maintained minimal account data to avoid this.
  • Loading branch information
fcayre committed Oct 13, 2023
1 parent b4aa045 commit 0f03109
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions commown_contract_forecast/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from dateutil.relativedelta import relativedelta

from odoo import tools
from odoo.modules.module import get_resource_path
from odoo.tests.common import at_install, post_install

from odoo.addons.product_rental.tests.common import RentalSaleOrderTC
Expand All @@ -22,6 +24,22 @@ def setUp(self):
)
)

if not self.env["account.journal"].search([("type", "=", "sale")]):
# When running in a db where the commown module is not installed
# (=not the in the CI), no dependency module sets up accounting
# and invoice generation crashes; following inserts the minimal
# data needed to avoid this:
tools.convert_file(
self.cr,
"commown_contract_forecast",
get_resource_path("account", "test", "account_minimal_test.xml"),
{},
"init",
False,
"test",
self.registry._assertion_report,
)

def test_contract_life_cycle(self):
"Forecast computations should be triggered when (and only when) needed"

Expand Down

0 comments on commit 0f03109

Please sign in to comment.