Skip to content

Commit

Permalink
[IMP] queue_job: Cancel child jobs when the parent is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
QuocDuong1306 authored and thienvh332 committed Oct 7, 2024
1 parent 4fc6ddc commit fe659d7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test_queue_job/tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
RetryableJobError,
)
from odoo.addons.queue_job.job import (
CANCELLED,
DONE,
ENQUEUED,
FAILED,
Expand Down Expand Up @@ -548,6 +549,24 @@ def test_button_done_enqueue_waiting_dependencies(self):
self.assertEqual(record_root.state, DONE)
self.assertEqual(record_child.state, PENDING)

def test_button_cancel_dependencies(self):
job_root = Job(self.env["test.queue.job"].testing_method)
job_child = Job(self.env["test.queue.job"].testing_method)
job_child.add_depends({job_root})

DelayableGraph._ensure_same_graph_uuid([job_root, job_child])
job_root.store()
job_child.store()

self.assertEqual(job_child.state, WAIT_DEPENDENCIES)
record_root = job_root.db_record()
record_child = job_child.db_record()
# Trigger button cancelled
record_root.button_cancelled()
# Check the state
self.assertEqual(record_root.state, CANCELLED)
self.assertEqual(record_child.state, CANCELLED)

def test_requeue(self):
stored = self._create_job()
stored.write({"state": "failed"})
Expand Down

0 comments on commit fe659d7

Please sign in to comment.