queue icon indicating copy to clipboard operation
queue copied to clipboard

[17.0][Question] How to pass a job’s result to a dependent chained job?

Open rafinhaLima opened this issue 5 months ago • 1 comments

I saw in the documentation that it’s possible to use chains and groups to build a graph of job execution. However, one question came to my mind: if Job 2 depends on the result of Job 1, how can I chain them and pass Job 1’s result into Job 2?

Is there currently a method or pattern supported by the framework to achieve this?

rafinhaLima avatar Sep 04 '25 03:09 rafinhaLima

Please try this and write if it worked.

class MyExampleClass(models.Model):
    def create_jobs(self):
        job2 = (
            self
            .delayable()
        )
        job1 = (
            self
            .delayable()
            .my_method_1()
            .on_done(job2)
        )
        job2 = (
            job2
            .my_method_2(job1._build_job().uuid)
        )
        job1.delay()

    def my_method_1(self):
        return "Hello"

    def my_method_2(self, job_uuid: str):
        queue_job = self.env["queue.job"].browse([("uuid", "=", job_uuid)])
        queue_job_results = queue_job.result
        return f"{queue_job_results}, World!"

SGmuwa avatar Oct 07 '25 12:10 SGmuwa