From 5788a157c57d689ceb00efa904eccc9892eefb67 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 24 Oct 2024 10:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 ++-- .../models/sf_message_maintenance_logs.py | 12 +++++------ sf_message/models/sf_message_sale.py | 20 +++++++++++++++---- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 2a1bfdd2..8e81d076 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_maintenance_logs.py b/sf_message/models/sf_message_maintenance_logs.py index 115d073b..288043ff 100644 --- a/sf_message/models/sf_message_maintenance_logs.py +++ b/sf_message/models/sf_message_maintenance_logs.py @@ -4,12 +4,12 @@ class SFMessageMaintenanceLogs(models.Model): _name = 'sf.maintenance.logs' _inherit = ['sf.maintenance.logs', 'jikimo.message.dispatch'] - # @api._model_create_multi - # def create(self, vals_list): - # res = super(SFMessageMaintenanceLogs, self).create(vals_list) - # for rec in res: - # rec.add_queue() - # return res + @api._model_create_multi + def create(self, vals_list): + res = super(SFMessageMaintenanceLogs, self).create(vals_list) + for rec in res: + rec.add_queue() + return res def _get_message(self, message_queue_ids): contents = super(SFMessageMaintenanceLogs, self)._get_message(message_queue_ids) diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index 5f517d8d..bc2c2d11 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -103,23 +103,35 @@ class SFMessageSale(models.Model): today = datetime.today().date() deadline_check = today + timedelta(days=1) logging.info(f"today: {today}, deadline_check: {deadline_check}") - sale_order = self.sudo().search([('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False)]) + 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'])) - if len(production_not_done) != item.mrp_production_count: + if len(production_not_done) >= 1 and len(production_not_done) != 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}") 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']: + 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}") 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']: + elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']: item.delivery_warning = 'overdue' else: + logging.info("-----1111111----") continue # 获取业务节点 business_node_ids = { diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index cb1886a1..081807a4 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 9bd61132..4756a2c5 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