From 9d133096c752191e42e535fe8b449455f5eb24ac Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 25 Oct 2024 09:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=E6=97=B6=E5=8C=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 +-- sf_message/models/sf_message_sale.py | 37 +++++++++++++++++---- sf_sale/models/quick_easy_order.py | 4 +-- sf_sale/models/quick_easy_order_old.py | 4 +-- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 3b8ed0a6..f2dc5046 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index 9907dbc9..da4c32f6 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -100,15 +100,22 @@ class SFMessageSale(models.Model): # # 销售订单逾期预警和已逾期 def _overdue_or_warning_func(self): - today = datetime.today().date() - deadline_check = today + timedelta(days=1) - logging.info(f"today: {today}, deadline_check: {deadline_check}") + current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf) + 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( [('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')]) for item in sale_order: production = self.env['mrp.production'].search([('origin', '=', item.name)]) 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'])) + 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( production_not_done) != production_done_count: # logging.info("-----不等于----") @@ -116,9 +123,9 @@ class SFMessageSale(models.Model): # 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']: + if deadline_check == 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']: + elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']: item.delivery_warning = 'overdue' elif production_done_count == item.mrp_production_count: # logging.info("-----等于----") @@ -127,9 +134,9 @@ class SFMessageSale(models.Model): # 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']: + if deadline_check == 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']: + elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']: item.delivery_warning = 'overdue' else: # logging.info("-----1111111----") @@ -158,6 +165,22 @@ class SFMessageSale(models.Model): if not sale_order_has: message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期' 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) + 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): sale_order_done = self.sudo().search([('state', 'in', ['sale']), ('delivery_status', '=', 'full')]) diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 081807a4..cb1886a1 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 4756a2c5..9bd61132 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path