[英]Odoo11 - Display pop up message with a cron task
I created a cron to compare the quantity of product in stock and the minimum quantity in the rules. 我创建了一个cron来比较库存产品数量和规则中的最小数量。 I would like that every time the quantity in stock is lower than the minimum of the rules it shows me a popup.
我希望每次库存数量低于规则的最小值时,它都会向我显示一个弹出窗口。
When I run the cron automatically it does not display a message or error 当我自动运行cron时,它不会显示任何消息或错误
Here is my code: 这是我的代码:
@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在运行时在odoo的后端运行cron并不会影响odoo的运行环境,它在另一个环境中运行时,您可以在日志中看到它们,但不会影响您的运行环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.