Skip to content

[18.0][IMP] queue_job: Implement on fail hook - #971

Open
simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-on-fail-hook
Open

[18.0][IMP] queue_job: Implement on fail hook#971
simahawk wants to merge 1 commit into
OCA:18.0from
camptocamp:18-on-fail-hook

Conversation

@simahawk

Copy link
Copy Markdown
Contributor

Backport of #955

Allows to execute a model function when the job fails and will not be retried.

Allows to execute a model function when the job fails and will
not be retried.

[REF] queue_job: Move on fail definition to job function

Rename on_fail_hook to on_fail
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @guewen, @sbidoul,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:queue_job Module queue_job mod:test_queue_job Module test_queue_job series:18.0 labels Aug 27, 2026

@SilvioC2C SilvioC2C left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

Comment on lines +13 to +19
def setUp(cls):
super().setUp()

def _clean_queue_job():
cls.env["queue.job"].search([]).unlink()

cls.addCleanup(_clean_queue_job)

@SilvioC2C SilvioC2C Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: isn't this equivalent to:

Suggested change
def setUp(cls):
super().setUp()
def _clean_queue_job():
cls.env["queue.job"].search([]).unlink()
cls.addCleanup(_clean_queue_job)
def tearDown(self):
self.env["queue.job"].search([]).unlink()
super().tearDown()

Also, setUp is not decorated via @classmethod, so its first argument should be self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants