diff --git a/sf_message/data/bussiness_node.xml b/sf_message/data/bussiness_node.xml
index 8864beda..b273fab1 100644
--- a/sf_message/data/bussiness_node.xml
+++ b/sf_message/data/bussiness_node.xml
@@ -135,5 +135,10 @@
工序外协采购单通知
purchase.order
+
+
+ 工序外协发料通知
+ mrp.production
+
\ No newline at end of file
diff --git a/sf_message/data/template_data.xml b/sf_message/data/template_data.xml
index b7e19a7b..e9aee4bb 100644
--- a/sf_message/data/template_data.xml
+++ b/sf_message/data/template_data.xml
@@ -347,8 +347,20 @@
markdown
normal
### 工序外协采购单通知:
-单号:工序外协采购单产品[{{name}}]({{url}})
-事项:有{{num}}个工序外协采购单需要确认。
+单号:工序外协采购,产品[{{name}}]({{url}})
+事项:请确认{{num}}个工序外协采购单并处理。
+
+
+
+ 工序外协发料通知
+
+ mrp.production
+
+ markdown
+ normal
+ ### 工序外协发料提醒:
+单号:产品[{{name}}]({{url}})发料单
+事项:请确认{{num}}个工序外协发料单并发料处理。
\ No newline at end of file
diff --git a/sf_message/models/sf_message_mrp_production.py b/sf_message/models/sf_message_mrp_production.py
index 00748511..37509e52 100644
--- a/sf_message/models/sf_message_mrp_production.py
+++ b/sf_message/models/sf_message_mrp_production.py
@@ -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)
diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py
index 38a6fc16..4637941b 100644
--- a/sf_message/models/sf_message_stock_picking.py
+++ b/sf_message/models/sf_message_stock_picking.py
@@ -21,7 +21,7 @@ class SFMessageStockPicking(models.Model):
def _compute_state(self):
super(SFMessageStockPicking, self)._compute_state()
for record in self:
- if record.state == 'assigned' and record.check_in == 'PC':
+ if record.state == 'assigned' and record.picking_type_id.sequence_code == 'PC':
record.add_queue('坯料发料提醒')
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
@@ -32,6 +32,16 @@ class SFMessageStockPicking(models.Model):
stock_picking_send = self.env["jikimo.message.queue"].sudo().search([('res_id', '=', record.id)])
if not stock_picking_send:
record.add_queue('订单发货提醒')
+ if record.picking_type_id.sequence_code == 'OCOUT' and record.state == 'assigned':
+ mrp_production = self.env['mrp.production'].sudo().search([('name', '=', record.origin)])
+ production_list = self.env['mrp.production'].sudo().search(
+ [('product_id', '=', mrp_production.product_id.id)])
+ manufacturing_order_names = production_list.mapped('name')
+ stock_picking_list = self.env['stock.picking'].sudo().search(
+ [('origin', 'in', manufacturing_order_names), ('picking_type_id.sequence_code', '=', 'OCOUT')])
+ all_ready_or_done = all(picking.state in ['assigned', 'done'] for picking in stock_picking_list)
+ if all_ready_or_done:
+ mrp_production.add_queue('工序外协发料通知')
def deal_stock_picking_sfp(self, message_queue_id): # 处理订单发货提醒
content = None