修复日计划工单接口

This commit is contained in:
jinling.yang
2024-02-29 17:16:27 +08:00
parent ceffbd012e
commit 51c6b7ef9b
3 changed files with 12 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import time
import time, datetime
import hashlib
from odoo import models

View File

@@ -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}

View File

@@ -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)