Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Odoo11-显示带有cron任务的弹出消息_Python_Odoo 11 - Fatal编程技术网

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

Python Odoo11-显示带有cron任务的弹出消息,python,odoo-11,Python,Odoo 11,我创建了一个cron来比较库存产品的数量和规则中的最小数量。我想,每次库存量低于最低的规则,它显示我一个弹出窗口 当我自动运行cron时,它不会显示消息或错误 这是我的密码: @api.model def to_do(self): res_warehouse = self.env['stock.warehouse.orderpoint'].search([]) for product in res_warehouse: quants = self.env['sto

我创建了一个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
                }
@api.model
def to_do(自我):
res_warehouse=self.env['stock.warehouse.orderpoint'].search([])
对于仓库中的产品:
quants=self.env['stock.quant'].search([
['product_id','=',product.product_id.id],
['location\u id','=',product.location\u id.id],
]).mapped('数量')
如果数量:
view=self.env.ref('stock\u limit\u alert.cron\u wizard')
view\u id=view和view.id或False
context=dict(self.\u context或{})
上下文['message']=“确定”
上下文['params']={'nom':product.location_id.id}

如果quants[0]不可能这样,因为cron在odoo的后端运行,当cron运行时,它不会影响您的odoo运行环境它在另一个环境中工作,您可以在日志中看到它们,但它不会影响您的运行环境