修复工单提醒
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_jikimo_workorder_exception","access.jikimo.workorder.exception","model_jikimo_workorder_exception","mrp.group_mrp_user",1,1,1,0
|
||||
"access_jikimo_workorder_exception_group_quality","access.jikimo.workorder.exception.group_quality","model_jikimo_workorder_exception","sf_base.group_quality",1,1,1,0
|
||||
"access_jikimo_workorder_exception_group_quality_director","access.jikimo.workorder.exception.group_quality_director","model_jikimo_workorder_exception","sf_base.group_quality_director",1,1,1,0
|
||||
|
||||
|
||||
|
@@ -111,31 +111,31 @@ class SFMessageSale(models.Model):
|
||||
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
||||
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
||||
production_not_done) != production_done_count:
|
||||
logging.info("-----不等于----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
# logging.info("-----不等于----")
|
||||
# logging.info(f"name: {item.name}")
|
||||
# logging.info(
|
||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||
item.delivery_warning = 'warning'
|
||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||
item.delivery_warning = 'overdue'
|
||||
elif production_done_count == item.mrp_production_count:
|
||||
logging.info("-----等于----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
# logging.info("-----等于----")
|
||||
# logging.info(f"name: {item.name}")
|
||||
# logging.info(
|
||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
if item.delivery_status in ['pending', 'partial']:
|
||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||
item.delivery_warning = 'warning'
|
||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||
item.delivery_warning = 'overdue'
|
||||
else:
|
||||
logging.info("-----1111111----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
# logging.info("-----1111111----")
|
||||
# logging.info(f"name: {item.name}")
|
||||
# logging.info(
|
||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
continue
|
||||
# 获取业务节点
|
||||
business_node_ids = {
|
||||
|
||||
@@ -127,10 +127,14 @@ class SFMessageWork(models.Model):
|
||||
f"Planned Finish: {date_planned_finished}")
|
||||
item.delivery_warning = 'warning'
|
||||
business_node_ids = {
|
||||
'装夹预调': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue_warning').id,
|
||||
'CNC加工': self.env.ref('sf_message.bussiness_mrp_workorder_cnc_overdue_warning').id,
|
||||
'解除装夹': self.env.ref('sf_message.bussiness_mrp_workorder_unclamp_overdue_warning').id,
|
||||
'表面工艺': self.env.ref('sf_message.bussiness_mrp_workorder_surface_overdue_warning').id,
|
||||
'装夹预调_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue').id,
|
||||
'装夹预调_warning': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue_warning').id,
|
||||
'CNC加工_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_cnc_overdue').id,
|
||||
'CNC加工_warning': self.env.ref('sf_message.bussiness_mrp_workorder_cnc_overdue_warning').id,
|
||||
'解除装夹_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_unclamp_overdue').id,
|
||||
'解除装夹_warning': self.env.ref('sf_message.bussiness_mrp_workorder_unclamp_overdue_warning').id,
|
||||
'表面工艺_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_surface_overdue').id,
|
||||
'表面工艺_warning': self.env.ref('sf_message.bussiness_mrp_workorder_surface_overdue_warning').id,
|
||||
}
|
||||
message_templates = {key: self.env["jikimo.message.template"].sudo().search([
|
||||
("model", "=", self._name),
|
||||
@@ -138,13 +142,17 @@ class SFMessageWork(models.Model):
|
||||
]) for key in business_node_ids}
|
||||
for item in orders:
|
||||
if item.delivery_warning in ['overdue', 'warning']:
|
||||
bussiness_node_id = business_node_ids.get(item.routing_type)
|
||||
if bussiness_node_id and message_templates[item.routing_type]:
|
||||
warning_type = 'warning' if item.delivery_warning == 'warning' else 'overdue'
|
||||
key = f"{item.routing_type}_{warning_type}"
|
||||
bussiness_node_id = business_node_ids.get(key, None)
|
||||
if bussiness_node_id:
|
||||
message_template = message_templates.get(key)
|
||||
if message_template and message_template.id:
|
||||
message_queue_ids = self.env["jikimo.message.queue"].sudo().search([
|
||||
("message_template_id", "=", message_templates[item.routing_type].id),
|
||||
("message_template_id", "=", message_template.id),
|
||||
("message_status", "=", "pending"),
|
||||
("res_id", "=", item.id)
|
||||
])
|
||||
], limit=1)
|
||||
if not message_queue_ids:
|
||||
overdue_message = '工单已逾期' if item.delivery_warning == 'overdue' else '工单逾期预警'
|
||||
queue_method_name = f'add_queue'
|
||||
|
||||
Reference in New Issue
Block a user