Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions queue_job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from . import wizards
from . import jobrunner
from .post_init_hook import post_init_hook
from .post_load import post_load

# shortcuts
from .job import identity_exact
1 change: 1 addition & 0 deletions queue_job/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
"development_status": "Mature",
"maintainers": ["guewen"],
"post_init_hook": "post_init_hook",
"post_load": "post_load",
}
25 changes: 25 additions & 0 deletions queue_job/post_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from odoo import http

_logger = logging.getLogger(__name__)


def post_load():
_logger.info(
"Apply Request._get_session_and_dbname monkey patch to capture db"
" from request with multiple databases"
)
_get_session_and_dbname_orig = http.Request._get_session_and_dbname

def _get_session_and_dbname(self):
session, dbname = _get_session_and_dbname_orig(self)
if (
not dbname
and self.httprequest.path == "/queue_job/runjob"
and self.httprequest.args.get("db")
):
dbname = self.httprequest.args["db"]
return session, dbname

http.Request._get_session_and_dbname = _get_session_and_dbname