消息提醒

This commit is contained in:
guanhuan
2024-12-19 13:09:20 +08:00
parent 79d188fb5c
commit 5eda4427df
4 changed files with 47 additions and 4 deletions

View File

@@ -50,6 +50,22 @@ class SFMessageMrpProduction(models.Model):
content = message_queue_id.message_template_id.content
mrp_production = self.env['mrp.production'].sudo().search([('id', '=', int(message_queue_id.res_id))])
unique_products.add(mrp_production.product_id.id)
if message_queue_id.message_template_id.name == '工序外协发料通知':
content = message_queue_id.message_template_id.content
mrp_production = self.env['mrp.production'].sudo().search([('id', '=', int(message_queue_id.res_id))])
mrp_production_list = self.env['mrp.production'].sudo().search(
[('product_id', '=', mrp_production.product_id.id)])
mrp_production_names = mrp_production_list.mapped('name')
stock_picking_num = self.env['stock.picking'].sudo().search_count(
[('origin', 'in', mrp_production_names), ('state', '=', 'assigned')])
if stock_picking_num >= 1:
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref('stock.action_picking_tree_ready').id
url_with_id = f"{url}/web#view_type=list&action={action_id}"
content = content.replace('{{name}}', mrp_production.product_id.name).replace('{{url}}',
url_with_id).replace(
'{{num}}', str(stock_picking_num))
contents.append(content)
if unique_products:
unique_products_contents = self.get_production_info(content, unique_products, 'confirmed',
'sf_plan.sf_production_plan_action1')
@@ -83,7 +99,7 @@ class SFMessageMrpProduction(models.Model):
action_id = self.env.ref('stock.action_picking_tree_all').id
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
# 查询参数
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'mrp.production',
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'mrp.production',
'view_type': 'form'}
# 拼接查询参数
query_string = urlencode(params)