From 51c6b7ef9b242b6193ed9772aac16eee6768da05 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 29 Feb 2024 17:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/commons/common.py | 2 +- sf_manufacturing/controllers/controllers.py | 6 ++++-- sf_manufacturing/models/mrp_workorder.py | 12 +++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sf_base/commons/common.py b/sf_base/commons/common.py index 6bf597cc..b423e160 100644 --- a/sf_base/commons/common.py +++ b/sf_base/commons/common.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import time +import time, datetime import hashlib from odoo import models diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 3a192e82..9063f518 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -72,14 +72,16 @@ class Manufacturing_Connect(http.Controller): date_planned_start = '' date_planned_finished = '' if item.date_planned_start is not False: + logging.info('date_planned_start:%s' % item.date_planned_start) planned_start = item.date_planned_start.strftime("%Y-%m-%d %H:%M:%S") date_planned_start = request.env['sf.sync.common'].sudo().get_add_time(planned_start) if item.date_planned_finished is not False: + logging.info('date_planned_finished:%s' % item.date_planned_finished) planned_finished = item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S") date_planned_finished = request.env['sf.sync.common'].sudo().get_add_time(planned_finished) res['Datas'].append({ 'BillId': item.production_id.name, - 'RfidCode': item.RfidCode, + 'RfidCode': item.rfid_code, 'CraftName': item.name, 'Quantity': 1, 'WortkStart': date_planned_start, @@ -87,7 +89,7 @@ class Manufacturing_Connect(http.Controller): 'MaterialId': item.product_id.default_code, 'MaterialName': item.product_id.name, # 'Spec':item.mat, - 'Material': item.materials_type_id.name + 'Material': item.product_id.materials_type_id.name }) except Exception as e: res = {'Succeed': False, 'ErrorCode': 202, 'Error': e} diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 6561d808..a7408be8 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -142,15 +142,17 @@ class ResMrpWorkOrder(models.Model): def get_plan_workorder(self, production_line): tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d") + tomorrow_start = tomorrow + ' 00:00:00' + tomorrow_end = tomorrow + ' 23:59:59' + logging.info('tomorrow:%s' % tomorrow) sql = """ SELECT * FROM mrp_workorder - WHERE date_planned_start = %s::timestamp - AND date_planned_start < (%s::timestamp + interval '1 day') - AND date_planned_finished >= %s::timestamp - AND date_planned_finished < (%s::timestamp + interval '1 day') + WHERE + to_char(date_planned_start::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')>= %s + AND to_char(date_planned_finished::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')<= %s """ - params = [tomorrow, tomorrow, tomorrow, tomorrow] + params = [tomorrow_start, tomorrow_end] if production_line: sql += "AND production_line_id = %s" params.append(production_line)