From 1a16788b1db7ea4e7e15425080c6f9deddeb00a2 Mon Sep 17 00:00:00 2001 From: Adam Heinz Date: Mon, 23 Dec 2024 11:44:38 -0500 Subject: [PATCH] [FIX] Stop using deprecated odoo.registry function. This avoids a DeprecationWarning introduced in Odoo 17 by https://github.com/odoo/odoo/pull/178784 > WARNING odoo py.warnings: /mnt/extra-addons/oca/queue/queue_job/controllers/main.py:82: DeprecationWarning: Use directly odoo.modules.registry.Registry --- queue_job/controllers/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/queue_job/controllers/main.py b/queue_job/controllers/main.py index 13288f03de..15522e7321 100644 --- a/queue_job/controllers/main.py +++ b/queue_job/controllers/main.py @@ -11,7 +11,8 @@ from psycopg2 import OperationalError, errorcodes from werkzeug.exceptions import BadRequest, Forbidden -from odoo import SUPERUSER_ID, _, api, http, registry +from odoo import SUPERUSER_ID, _, api, http +from odoo.modules.registry import Registry from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY from ..delay import chain, group @@ -79,7 +80,7 @@ def runjob(self, db, job_uuid, **kw): def retry_postpone(job, message, seconds=None): job.env.clear() - with registry(job.env.cr.dbname).cursor() as new_cr: + with Registry(job.env.cr.dbname).cursor() as new_cr: job.env = api.Environment(new_cr, SUPERUSER_ID, {}) job.postpone(result=message, seconds=seconds) job.set_pending(reset_retry=False) @@ -130,7 +131,7 @@ def retry_postpone(job, message, seconds=None): traceback_txt = buff.getvalue() _logger.error(traceback_txt) job.env.clear() - with registry(job.env.cr.dbname).cursor() as new_cr: + with Registry(job.env.cr.dbname).cursor() as new_cr: job.env = job.env(cr=new_cr) vals = self._get_failure_values(job, traceback_txt, orig_exception) job.set_failed(**vals)