Skip to content

Commit 123fa8c

Browse files
committed
[FIX] queue_job: Fix migration script
1 parent 7d5e536 commit 123fa8c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

queue_job/migrations/12.0.2.3.0/post-migration.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,25 @@ def migrate(cr, version):
1313
_logger.info("Computing exception name for failed jobs")
1414
_compute_jobs_new_values(env)
1515

16-
1716
def _compute_jobs_new_values(env):
18-
for job in env["queue.job"].search(
17+
job_exc_infos = env["queue.job"].search(
1918
[("state", "=", "failed"), ("exc_info", "!=", False)]
20-
):
21-
exception_details = _get_exception_details(job)
19+
).read(fields=["exc_info"])
20+
for job_row in job_exc_infos:
21+
exception_details = _get_exception_details(job_row["exc_info"])
2222
if exception_details:
23-
job.update(exception_details)
24-
23+
job = env["queue.job"].browse(job_row["id"])
24+
job.write(exception_details)
2525

26-
def _get_exception_details(job):
27-
for line in reversed(job.exc_info.splitlines()):
26+
def _get_exception_details(exc_info):
27+
for line in reversed(exc_info.splitlines()):
2828
if _find_exception(line):
2929
name, msg = line.split(":", 1)
3030
return {
3131
"exc_name": name.strip(),
3232
"exc_message": msg.strip("()', \""),
3333
}
3434

35-
3635
def _find_exception(line):
3736
# Just a list of common errors.
3837
# If you want to target others, add your own migration step for your db.

0 commit comments

Comments
 (0)