Odoo11 - 显示带有 cron 任务的弹出消息



我创建了一个 cron 来比较库存产品的数量和规则中的最小数量。我希望每次库存数量低于规则的最小值时,它都会向我显示一个弹出窗口。

当我自动运行 cron 时,它不显示消息或错误

这是我的代码:

@api.model
def to_do(self):
    res_warehouse = self.env['stock.warehouse.orderpoint'].search([])
    for product in res_warehouse:
        quants = self.env['stock.quant'].search([
            ['product_id', '=', product.product_id.id],
            ['location_id', '=', product.location_id.id],
        ]).mapped('quantity')
        if quants:
            view = self.env.ref('stock_limit_alert.cron_wizard')
            view_id = view and view.id or False
            context = dict(self._context or {})
            context['message'] = 'OK'
            context['params'] = {'nom': product.location_id.id}
            if quants[0] <= product.product_min_qty:
                return {
                    'name':'Success',
                    'type': 'ir.actions.act_window',
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'cron.wizard',
                    'views': [(view.id,'form')],
                    'view_id': view.id,
                    'target': 'new',
                    'context': context
                }

这是不可能的,因为当 cron 运行时,cron 正在 odoo 的后端运行,它不会影响您在另一个环境中工作的 odoo 运行环境,您可以在日志中看到它们,但它不会影响您的运行环境。

最新更新