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

问题描述 投票:0回答:1

我创建了一个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
                }
python odoo-11
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.