Skip to content

Commit

Permalink
[FIX] Stop using deprecated odoo.registry function.
Browse files Browse the repository at this point in the history
This avoids a DeprecationWarning introduced in Odoo 17 by odoo/odoo#178784

> WARNING odoo py.warnings: /mnt/extra-addons/oca/queue/queue_job/controllers/main.py:82: DeprecationWarning: Use directly odoo.modules.registry.Registry
  • Loading branch information
amh-mw committed Dec 23, 2024
1 parent 96ea979 commit 1a16788
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Check warning on line 83 in queue_job/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

queue_job/controllers/main.py#L83

Added line #L83 was not covered by tests
job.env = api.Environment(new_cr, SUPERUSER_ID, {})
job.postpone(result=message, seconds=seconds)
job.set_pending(reset_retry=False)
Expand Down Expand Up @@ -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:

Check warning on line 134 in queue_job/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

queue_job/controllers/main.py#L134

Added line #L134 was not covered by tests
job.env = job.env(cr=new_cr)
vals = self._get_failure_values(job, traceback_txt, orig_exception)
job.set_failed(**vals)
Expand Down

0 comments on commit 1a16788

Please sign in to comment.