Accept Merge Request #1652: (feature/消息提醒优化 -> develop)

Merge Request: 工单已下发提醒

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1652
This commit is contained in:
管欢
2024-12-26 17:18:09 +08:00
committed by Coding
3 changed files with 26 additions and 15 deletions

View File

@@ -13,8 +13,15 @@ class SFMessagePlan(models.Model):
if message_queue_id.message_template_id.name == '工单已下发通知':
content = message_queue_id.message_template_id.content
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
production_num = self.env['mrp.production'].sudo().search_count(
mrp_production_list = self.env['mrp.production'].sudo().search(
[('product_id', '=', product_product.id)])
production_num = 0
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(
lambda w: w.routing_type == routing_type and w.state == 'ready')
if mrp_production_ready:
production_num += 1
if production_num >= 1:
url = self.get_request_url()
content = content.replace('{{product_id}}', product_product.name).replace(

View File

@@ -72,14 +72,13 @@ class SFMessageStockPicking(models.Model):
content = message_queue_id.message_template_id.content
stock_picking_line = self.env['stock.picking'].sudo().search(
[('id', '=', int(message_queue_id.res_id))])
if stock_picking_line.state == 'assigned':
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref('stock.action_picking_tree_ready').id
menu_id = self.env.ref('stock.menu_stock_root').id
url_with_id = f"{url}/web#view_type=form&action={action_id}&menu_id={menu_id}&id={stock_picking_line.id}"
content = content.replace('{{name}}', stock_picking_line.name).replace(
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref('stock.action_picking_tree_ready').id
menu_id = self.env.ref('stock.menu_stock_root').id
url_with_id = f"{url}/web#view_type=form&action={action_id}&menu_id={menu_id}&id={stock_picking_line.id}"
content = content.replace('{{name}}', stock_picking_line.name).replace(
'{{request_url}}', url_with_id)
contents.append(content)
contents.append(content)
elif message_queue_id.message_template_id.name == '订单发货提醒':
content = self.deal_stock_picking_sfp(message_queue_id)
if content:

View File

@@ -18,16 +18,21 @@ class SFMessageWork(models.Model):
def _compute_state(self):
super(SFMessageWork, self)._compute_state()
for workorder in self:
min_sequence_wk = None
work_ids = workorder.production_id.workorder_ids.filtered(lambda w: w.routing_type == '装夹预调')
if work_ids:
min_sequence_wk = work_ids.sorted(key=lambda w: w.sequence)[0]
if workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id:
message_template = self.env["jikimo.message.template"].sudo().search([("name", "=", '工单已下发通知')], limit=1)
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
[('res_id', '=', workorder.production_id.product_id.id), ("message_status", "in", ("pending", "sent")),
('message_template_id', '=', message_template.id)])
if not jikimo_message_queue:
workorder.production_id.product_id.add_queue('工单已下发通知')
if (
workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id) or (
workorder.state == 'ready' and workorder.routing_type == '人工线下加工'):
message_template = self.env["jikimo.message.template"].sudo().search(
[("name", "=", '工单已下发通知')], limit=1)
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
[('res_id', '=', workorder.production_id.product_id.id),
("message_status", "in", ("pending", "sent")),
('message_template_id', '=', message_template.id)])
if not jikimo_message_queue:
workorder.production_id.product_id.add_queue('工单已下发通知')
def _get_message(self, message_queue_ids):
contents = []