From fd9018a4c89feb6ee83b3789733099238a4fbaa6 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 25 Mar 2025 09:56:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=8C=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 43af4a9b..0c91846b 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -566,7 +566,8 @@ class Sf_Dashboard_Connect(http.Controller): :return: """ res = {'status': 1, 'message': '成功', 'data': {}} - plan_obj = request.env['sf.production.plan'].sudo() + # plan_obj = request.env['sf.production.plan'].sudo() + plan_obj = request.env['mrp.production'].sudo() line_list = ast.literal_eval(kw['line_list']) begin_time_str = kw['begin_time'].strip('"') end_time_str = kw['end_time'].strip('"') @@ -604,7 +605,7 @@ class Sf_Dashboard_Connect(http.Controller): return date_list for line in line_list: - date_field_name = 'actual_end_time' # 替换为你模型中的实际字段名 + date_field_name = 'date_finished' # 替换为你模型中的实际字段名 order_counts = [] if time_unit == 'hour': @@ -618,7 +619,7 @@ class Sf_Dashboard_Connect(http.Controller): orders = plan_obj.search([ ('production_line_id.name', '=', line), - ('state', 'in', ['finished']), + ('state', 'in', ['done']), (date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')), (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间 ]) @@ -637,18 +638,18 @@ class Sf_Dashboard_Connect(http.Controller): for date in date_list: next_day = date + timedelta(days=1) - orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['finished']), + orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['done']), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) rework_orders = plan_obj.search( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['rework']), + [('production_line_id.name', '=', line), ('state', 'in', ['rework']), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) not_passed_orders = plan_obj.search( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['scrap', 'cancel']), + [('production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ])