Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 4fc4f80

Browse files
KKamaaTom Blauwendraat
authored andcommitted
[FIX] use JSON decoder class
1 parent c761ca2 commit 4fc4f80

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

queue_job/job.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from datetime import datetime, timedelta
1313

1414
import odoo
15-
from odoo.tools.safe_eval import safe_eval
15+
from odoo.addons.queue_job.fields import JobEncoder, JobDecoder
1616

1717
from .exception import (NoSuchJobError,
1818
FailedJobError,
@@ -515,7 +515,7 @@ def store(self):
515515
context = {}
516516
if self.keep_context:
517517
context = self.env.context.copy()
518-
vals.update({"context": json.dumps(context)})
518+
vals.update({"context": json.dumps(context, cls=JobEncoder)})
519519
if self.date_enqueued:
520520
vals['date_enqueued'] = dt_to_string(self.date_enqueued)
521521
if self.date_started:
@@ -534,7 +534,8 @@ def store(self):
534534
date_created = dt_to_string(self.date_created)
535535
# We store the original context used at import on create
536536
ctx = self.env.context.copy() or '{}'
537-
vals.update({'original_context': json.dumps(ctx) or ''})
537+
vals.update({'original_context': json.dumps(
538+
ctx, cls=JobEncoder) or ''})
538539
# The following values must never be modified after the
539540
# creation of the job
540541
vals.update({'uuid': self.uuid,
@@ -551,15 +552,15 @@ def store(self):
551552
if self.channel:
552553
vals.update({'channel': self.channel})
553554

554-
job = self.env[self.job_model_name].sudo().create(vals)
555+
self.env[self.job_model_name].sudo().create(vals)
555556

556557
def db_record(self):
557558
return self.db_record_from_uuid(self.env, self.uuid)
558559

559560
def _get_abs_context(self, original_ctx, ctx):
560561
try:
561-
import_ctx = json.loads(original_ctx)
562-
current_ctx = json.loads(ctx)
562+
import_ctx = json.loads(original_ctx, cls=JobDecoder, env=self.env)
563+
current_ctx = json.loads(ctx, cls=JobDecoder, env=self.env)
563564
except Exception as e:
564565
_logger.error("\n\nERROR CONTEXT JSON CONVERSION: %s\n\n" % e)
565566
return self.env.context.copy()

0 commit comments

Comments
 (0)