From e9ab4270a9740da2061c45d78d2aa3ba3fccb63c Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 23 Sep 2024 14:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AE=B0=E5=BD=95=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=9D=A1=E4=BB=B6=EF=BC=9B=E4=BC=98=E5=8C=96=E6=8E=92?= =?UTF-8?q?=E7=A8=8B=E5=8D=95=E7=8A=B6=E6=80=81=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 13 ++++++++----- sf_manufacturing/models/mrp_workorder.py | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 23452b43..fb783666 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -489,11 +489,14 @@ class Sf_Dashboard_Connect(http.Controller): for time_interval in time_intervals: start_time, end_time = time_interval - # print(start_time, end_time) - orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['finished']), - (date_field_name, '>=', start_time.strftime('%Y-%m-%d 00:00:00')), - (date_field_name, '<', end_time.strftime('%Y-%m-%d 00:00:00')) - ]) + + orders = plan_obj.search([ + ('production_line_id.name', '=', line), + ('state', 'in', ['finished']), + (date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')), + (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间 + ]) + # 使用小时和分钟作为键,确保每个小时的数据有独立的键 key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键 time_count_dict[key] = len(orders) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 5a78f36b..7c3ec50f 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1082,6 +1082,12 @@ class ResMrpWorkOrder(models.Model): # 重写工单开始按钮方法 def button_start(self): + if self.routing_type == 'CNC加工': + self.env['sf.production.plan'].sudo().search([('name', '=', self.production_id.name)]).write({ + 'state': 'processing', + 'actual_start_time': datetime.now() + }) + if self.routing_type == '装夹预调': # 判断是否有坯料的序列号信息 boolean = False