From 06dd9c12e0a2fca3838a027b09903d5c018ddf89 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 6 Feb 2025 10:43:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E7=BA=BF=E4=B8=8B=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E5=B7=A5=E5=8D=95=E4=B8=8B=E5=8F=91=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/models/sf_message_product.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sf_message/models/sf_message_product.py b/sf_message/models/sf_message_product.py index 0f2cfd7e..302aa5a0 100644 --- a/sf_message/models/sf_message_product.py +++ b/sf_message/models/sf_message_product.py @@ -16,6 +16,7 @@ class SFMessageProduct(models.Model): mrp_production_list = self.env['mrp.production'].sudo().search( [('product_id', '=', product_product.id)]) production_num = 0 + routing_type = None for mrp_production_info in mrp_production_list: routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调' mrp_production_ready = mrp_production_info.workorder_ids.filtered( @@ -23,7 +24,7 @@ class SFMessageProduct(models.Model): if mrp_production_ready: 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( '{{number}}', str(production_num)).replace( '{{request_url}}', url) @@ -42,11 +43,15 @@ class SFMessageProduct(models.Model): contents.append(content) 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') action_id = self.env.ref('sf_message.mrp_workorder_issued_action').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', 'view_type': 'list', 'active_id': active_id}