Search code examples
pythonodoo

how to use @job in odoo v15 queue_job?


In odoo v13 i use @job with 'from addons.queue_job.job import job, related_action' but now in odoo 15 I do not know how so how to use @job in odoo v15 queue_job ?


Solution

  • The decorator was removed, the PR with some more information is found here.

    So you need to write XML records for model queue.job.function like

    <record id="job_function_sale_order_action_done" model="queue.job.function">
        <field name="model_id" ref="sale.model_sale_order"</field>
        <field name="method">action_done</field>
        <field name="channel_id" ref="channel_sale" />
        <field name="related_action" eval='{"func_name": "custom_related_action"}' />
        <field name="retry_pattern" eval="{1: 60, 2: 180, 3: 10, 5: 300}" />
    </record>
    

    This example is from the modules readme for version 15.0.