Merge branch 'feature/修复消息提醒时区问题' into develop
This commit is contained in:
@@ -102,7 +102,7 @@
|
|||||||
<field name="target">current</field>
|
<field name="target">current</field>
|
||||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||||
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1}
|
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1,'search_default_filter_order_normal':1}
|
||||||
</field>
|
</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_workorder">
|
<p class="o_view_nocontent_workorder">
|
||||||
@@ -125,9 +125,9 @@
|
|||||||
<field name="model">mrp.workorder</field>
|
<field name="model">mrp.workorder</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!-- <xpath expr="//form" position="inside"> -->
|
<!-- <xpath expr="//form" position="inside"> -->
|
||||||
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
||||||
<!-- </xpath> -->
|
<!-- </xpath> -->
|
||||||
<xpath expr="//header/field[@name='state']" position="replace">
|
<xpath expr="//header/field[@name='state']" position="replace">
|
||||||
<field name="state" widget="statusbar"
|
<field name="state" widget="statusbar"
|
||||||
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
||||||
@@ -642,6 +642,7 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
|
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
|
||||||
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
|
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
|
||||||
|
<filter string="正常" name="filter_order_normal" domain="[('delivery_warning', '=', 'normal')]"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 销售订单逾期预警
|
<field name="content">### 销售订单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个销售订单有逾期风险
|
事项:[共有{{warning_num}}个销售订单有逾期风险]({{url}})
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">urgent</field>
|
<field name="urgency">urgent</field>
|
||||||
<field name="content">### 销售订单已逾期提醒
|
<field name="content">### 销售订单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个销售订单已逾期
|
事项:[共有{{overdue_num}}个销售订单已逾期]({{url}})
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_pre_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_pre_overdue" model="jikimo.message.template">
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_cnc_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_cnc_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_cnc_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_cnc_overdue" model="jikimo.message.template">
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_unclamp_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_unclamp_overdue" model="jikimo.message.template">
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_surface_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_surface_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_surface_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_surface_overdue" model="jikimo.message.template">
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 待质量判定提醒
|
<field name="content">### 待质量判定提醒
|
||||||
事项:共有[{{judge_num}}]({{url}})个工单需判定质量结果</field>
|
事项:[共有{{judge_num}}个工单需判定质量结果]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="template_maintenance_logs" model="jikimo.message.template">
|
<record id="template_maintenance_logs" model="jikimo.message.template">
|
||||||
<field name="name">设备故障</field>
|
<field name="name">设备故障</field>
|
||||||
|
|||||||
@@ -100,15 +100,22 @@ class SFMessageSale(models.Model):
|
|||||||
|
|
||||||
# # 销售订单逾期预警和已逾期
|
# # 销售订单逾期预警和已逾期
|
||||||
def _overdue_or_warning_func(self):
|
def _overdue_or_warning_func(self):
|
||||||
today = datetime.today().date()
|
current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
deadline_check = today + timedelta(days=1)
|
current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf)
|
||||||
logging.info(f"today: {today}, deadline_check: {deadline_check}")
|
today_str = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S')
|
||||||
|
today = today_str.strftime("%Y-%m-%d")
|
||||||
|
# 计算下一天的日期
|
||||||
|
deadline_check_str = today_str + timedelta(days=1)
|
||||||
|
deadline_check = deadline_check_str.strftime("%Y-%m-%d")
|
||||||
|
logging.info(
|
||||||
|
f"today: {today}, deadline_check: {deadline_check},current_time_strf: {current_time_strf}, current_time: {current_time}'")
|
||||||
sale_order = self.sudo().search(
|
sale_order = self.sudo().search(
|
||||||
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
||||||
for item in sale_order:
|
for item in sale_order:
|
||||||
production = self.env['mrp.production'].search([('origin', '=', item.name)])
|
production = self.env['mrp.production'].search([('origin', '=', item.name)])
|
||||||
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
||||||
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
||||||
|
deadline_of_delivery = item.deadline_of_delivery.strftime("%Y-%m-%d")
|
||||||
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
||||||
production_not_done) != production_done_count:
|
production_not_done) != production_done_count:
|
||||||
# logging.info("-----不等于----")
|
# logging.info("-----不等于----")
|
||||||
@@ -116,9 +123,9 @@ class SFMessageSale(models.Model):
|
|||||||
# logging.info(
|
# logging.info(
|
||||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
# 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(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
if deadline_check == deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
elif production_done_count == item.mrp_production_count:
|
elif production_done_count == item.mrp_production_count:
|
||||||
# logging.info("-----等于----")
|
# logging.info("-----等于----")
|
||||||
@@ -127,9 +134,9 @@ class SFMessageSale(models.Model):
|
|||||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
# 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(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
if item.delivery_status in ['pending', 'partial']:
|
if item.delivery_status in ['pending', 'partial']:
|
||||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
if deadline_check == deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
else:
|
else:
|
||||||
# logging.info("-----1111111----")
|
# logging.info("-----1111111----")
|
||||||
@@ -158,6 +165,23 @@ class SFMessageSale(models.Model):
|
|||||||
if not sale_order_has:
|
if not sale_order_has:
|
||||||
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
||||||
wo.add_queue(message_name)
|
wo.add_queue(message_name)
|
||||||
|
if wo.delivery_warning == 'overdue':
|
||||||
|
# 把消息队列中销售订单预警的状态改为取消发送
|
||||||
|
business_node_id_warning = business_node_ids['warning']
|
||||||
|
if business_node_id_warning:
|
||||||
|
message_template_warning = self.env["jikimo.message.template"].search([
|
||||||
|
("model", "=", self._name),
|
||||||
|
("bussiness_node_id", "=", business_node_id_warning)
|
||||||
|
], limit=1)
|
||||||
|
if message_template_warning:
|
||||||
|
sale_order_warning = self.env['jikimo.message.queue'].search([
|
||||||
|
('res_id', '=', wo.id),
|
||||||
|
('message_status', '=', 'pending'),
|
||||||
|
('message_template_id', '=', message_template_warning.id)
|
||||||
|
])
|
||||||
|
if sale_order_warning:
|
||||||
|
logging.info('取消发送:%s' % sale_order_warning.name)
|
||||||
|
sale_order_warning.write({'message_status': 'cancel'})
|
||||||
|
|
||||||
def _recover_sale_time_warning_func(self):
|
def _recover_sale_time_warning_func(self):
|
||||||
sale_order_done = self.sudo().search([('state', 'in', ['sale']), ('delivery_status', '=', 'full')])
|
sale_order_done = self.sudo().search([('state', 'in', ['sale']), ('delivery_status', '=', 'full')])
|
||||||
|
|||||||
@@ -71,10 +71,22 @@ class SFMessageWork(models.Model):
|
|||||||
('delivery_warning', '=', 'overdue')]
|
('delivery_warning', '=', 'overdue')]
|
||||||
record = self.sudo().search(search_condition + [('id', '=', int(message_queue_id.res_id))])
|
record = self.sudo().search(search_condition + [('id', '=', int(message_queue_id.res_id))])
|
||||||
if record:
|
if record:
|
||||||
|
bussiness_node = item.bussiness_node_id.name
|
||||||
|
# 分割业务节点名称,提取出业务节点关键字
|
||||||
|
business_node_key = bussiness_node.split('工单')[0].strip()
|
||||||
|
workcenter_mapping = {
|
||||||
|
'装夹预调': '工件装夹',
|
||||||
|
'CNC加工': '自动产线',
|
||||||
|
'解除装夹': '工件拆卸',
|
||||||
|
'表面工艺': '表面工艺外协',
|
||||||
|
}
|
||||||
|
workcenter_name = workcenter_mapping.get(business_node_key, '表面工艺外协')
|
||||||
|
active_id = self.env['mrp.workcenter'].search([('name', 'ilike', workcenter_name)],
|
||||||
|
limit=1).id
|
||||||
i += 1
|
i += 1
|
||||||
if i >= 1:
|
if i >= 1:
|
||||||
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
||||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
url_with_id = f"{url}/web#view_type=list&action={action_id}&active_id={active_id}"
|
||||||
content_template = content.replace('{{url}}', url_with_id)
|
content_template = content.replace('{{url}}', url_with_id)
|
||||||
if bussiness_node in template_names['预警']:
|
if bussiness_node in template_names['预警']:
|
||||||
content = content_template.replace('{{warning_num}}', str(i))
|
content = content_template.replace('{{warning_num}}', str(i))
|
||||||
@@ -160,6 +172,24 @@ class SFMessageWork(models.Model):
|
|||||||
args = [f'{item.routing_type}{overdue_message}']
|
args = [f'{item.routing_type}{overdue_message}']
|
||||||
# 获取add_queue方法并调用它,传入参数列表
|
# 获取add_queue方法并调用它,传入参数列表
|
||||||
getattr(item, queue_method_name)(*args)
|
getattr(item, queue_method_name)(*args)
|
||||||
|
if item.delivery_warning == 'overdue':
|
||||||
|
# 把消息队列中销售订单预警的状态改为取消发送
|
||||||
|
key = f"{item.routing_type}_{'warning'}"
|
||||||
|
business_node_id_warning = business_node_ids.get(key, None)
|
||||||
|
if business_node_id_warning:
|
||||||
|
message_template_warning = self.env["jikimo.message.template"].search([
|
||||||
|
("model", "=", self._name),
|
||||||
|
("bussiness_node_id", "=", business_node_id_warning)
|
||||||
|
], limit=1)
|
||||||
|
if message_template_warning:
|
||||||
|
work_order_warning = self.env['jikimo.message.queue'].search([
|
||||||
|
('res_id', '=', item.id),
|
||||||
|
('message_status', '=', 'pending'),
|
||||||
|
('message_template_id', '=', message_template_warning.id)
|
||||||
|
])
|
||||||
|
if work_order_warning:
|
||||||
|
logging.info('取消发送:%s' % work_order_warning.name)
|
||||||
|
work_order_warning.write({'message_status': 'cancel'})
|
||||||
|
|
||||||
def _recover_time_warning_func(self):
|
def _recover_time_warning_func(self):
|
||||||
workorder_done = self.env['mrp.workorder'].search([("state", "in", ["done", "rework", "cancel"])])
|
workorder_done = self.env['mrp.workorder'].search([("state", "in", ["done", "rework", "cancel"])])
|
||||||
|
|||||||
Reference in New Issue
Block a user