Skip to content

Commit

Permalink
[FIX] saas: merge database creation job, modules installing job and p…
Browse files Browse the repository at this point in the history
…ost init job into one queue job chain

This will escape situations, where modules installing job will start running when database is not created yet
  • Loading branch information
gaelTorrecillas authored and em230418 committed Nov 30, 2022
1 parent c933a6f commit c858615
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions saas/models/saas_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from odoo.tools.safe_eval import test_python_expr
from odoo.addons.http_routing.models.ir_http import slugify
from odoo.exceptions import ValidationError, UserError
from odoo.addons.queue_job.delay import group

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -221,13 +222,18 @@ def create_db(self, key_values=None, db_name=None, with_delay=True, draft_build_

self.env['saas.log'].log_db_creating(build, self.operator_db_id)
if with_delay:
build.with_delay().create_db(
self.operator_db_name,
self.template_id.template_demo,
job_create = build.with_delay().create_db(
self.operator_db_name, self.template_id.template_demo,
)
job_install_modules = group(job_create).on_done(
build.with_delay().action_install_missing_mandatory_modules()
)
build.with_delay().action_install_missing_mandatory_modules()

self.operator_id.with_delay().build_post_init(build, self.template_id.build_post_init, key_values)
group(job_install_modules).on_done(
self.operator_id.with_delay().build_post_init(
build, self.template_id.build_post_init, key_values
)
)
else:
build.create_db(
self.operator_db_name,
Expand Down

0 comments on commit c858615

Please sign in to comment.