人工线下加工工单下发通知修改

This commit is contained in:
guanhuan
2025-02-06 10:43:11 +08:00
parent 5636681ee6
commit 06dd9c12e0

View File

@@ -16,6 +16,7 @@ class SFMessageProduct(models.Model):
mrp_production_list = self.env['mrp.production'].sudo().search( mrp_production_list = self.env['mrp.production'].sudo().search(
[('product_id', '=', product_product.id)]) [('product_id', '=', product_product.id)])
production_num = 0 production_num = 0
routing_type = None
for mrp_production_info in mrp_production_list: for mrp_production_info in mrp_production_list:
routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调' routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调'
mrp_production_ready = mrp_production_info.workorder_ids.filtered( mrp_production_ready = mrp_production_info.workorder_ids.filtered(
@@ -23,7 +24,7 @@ class SFMessageProduct(models.Model):
if mrp_production_ready: if mrp_production_ready:
production_num += 1 production_num += 1
if production_num >= 1: if production_num >= 1:
url = self.get_request_url() url = self.get_request_url(routing_type)
content = content.replace('{{product_id}}', product_product.name).replace( content = content.replace('{{product_id}}', product_product.name).replace(
'{{number}}', str(production_num)).replace( '{{number}}', str(production_num)).replace(
'{{request_url}}', url) '{{request_url}}', url)
@@ -42,11 +43,15 @@ class SFMessageProduct(models.Model):
contents.append(content) contents.append(content)
return contents, message_queue_ids return contents, message_queue_ids
def get_request_url(self): def get_request_url(self, routing_type):
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
menu_id = self.env.ref('mrp.menu_mrp_root').id menu_id = self.env.ref('mrp.menu_mrp_root').id
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id if routing_type == '人工线下加工':
routing_name = '线下工作中心'
else:
routing_name = '工件装夹中心'
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', routing_name)]).id
# 查询参数 # 查询参数
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder', params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
'view_type': 'list', 'active_id': active_id} 'view_type': 'list', 'active_id': active_id}