Odoo16_queue_job第三方异步队列

1.安装第三方模块queue_job

  queue/queue_job at 16.0 · OCA/queue · GitHub

2.odoo配置文件,启动多workers

workers = 3
proxy_mode = True

server_wide_modules = web,queue_job
[queue_job]
channels = root:2

3.使用方法

from odoo import models, fields, api

class MyModel(models.Model):
   _name = 'my.model'

   def my_method(self, a, k=None):
       _logger.info('executed with a: %s and k: %s', a, k)


class MyOtherModel(models.Model):
    _name = 'my.other.model'

    def button_do_stuff(self):
        self.env['my.model'].with_delay().my_method('a', k=2)

4.

 

posted @ 2023-11-22 17:14  手可摘星辰。  阅读(307)  评论(0编辑  收藏  举报