修复日计划工单接口
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import time
|
import time, datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
|
||||||
|
|||||||
@@ -72,14 +72,16 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
date_planned_start = ''
|
date_planned_start = ''
|
||||||
date_planned_finished = ''
|
date_planned_finished = ''
|
||||||
if item.date_planned_start is not False:
|
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")
|
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)
|
date_planned_start = request.env['sf.sync.common'].sudo().get_add_time(planned_start)
|
||||||
if item.date_planned_finished is not False:
|
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")
|
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)
|
date_planned_finished = request.env['sf.sync.common'].sudo().get_add_time(planned_finished)
|
||||||
res['Datas'].append({
|
res['Datas'].append({
|
||||||
'BillId': item.production_id.name,
|
'BillId': item.production_id.name,
|
||||||
'RfidCode': item.RfidCode,
|
'RfidCode': item.rfid_code,
|
||||||
'CraftName': item.name,
|
'CraftName': item.name,
|
||||||
'Quantity': 1,
|
'Quantity': 1,
|
||||||
'WortkStart': date_planned_start,
|
'WortkStart': date_planned_start,
|
||||||
@@ -87,7 +89,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
'MaterialId': item.product_id.default_code,
|
'MaterialId': item.product_id.default_code,
|
||||||
'MaterialName': item.product_id.name,
|
'MaterialName': item.product_id.name,
|
||||||
# 'Spec':item.mat,
|
# 'Spec':item.mat,
|
||||||
'Material': item.materials_type_id.name
|
'Material': item.product_id.materials_type_id.name
|
||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
|||||||
@@ -142,15 +142,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
def get_plan_workorder(self, production_line):
|
def get_plan_workorder(self, production_line):
|
||||||
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
|
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 = """
|
sql = """
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM mrp_workorder
|
FROM mrp_workorder
|
||||||
WHERE date_planned_start = %s::timestamp
|
WHERE
|
||||||
AND date_planned_start < (%s::timestamp + interval '1 day')
|
to_char(date_planned_start::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')>= %s
|
||||||
AND date_planned_finished >= %s::timestamp
|
AND to_char(date_planned_finished::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')<= %s
|
||||||
AND date_planned_finished < (%s::timestamp + interval '1 day')
|
|
||||||
"""
|
"""
|
||||||
params = [tomorrow, tomorrow, tomorrow, tomorrow]
|
params = [tomorrow_start, tomorrow_end]
|
||||||
if production_line:
|
if production_line:
|
||||||
sql += "AND production_line_id = %s"
|
sql += "AND production_line_id = %s"
|
||||||
params.append(production_line)
|
params.append(production_line)
|
||||||
|
|||||||
Reference in New Issue
Block a user