1.新增自动化传递工单号获取工单信息接口

This commit is contained in:
jinling.yang
2024-01-15 17:31:15 +08:00
parent d0e92a649a
commit 1b490951b1
3 changed files with 42 additions and 0 deletions

View File

@@ -1 +1,2 @@
from . import models
from . import controllers

View File

@@ -0,0 +1 @@
from . import controllers

View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import logging
import json
import base64
from odoo import http
from odoo.http import request
class Manufacturing_Connect(http.Controller):
@http.route('/AutoDeviceApi/GetWoInfo', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_Work_Info(self, **kw):
"""
自动化传递工单号获取工单信息
:param kw:
:return:
"""
logging.info('get_Work_Info:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
logging.info('RfidCode:%s' % ret)
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['RfidCode'])])
if workorder:
for item in workorder:
res['Datas'].append({
'BillId': item.production_id.name,
'ProductionLine': item.production_line,
'CraftName': item.name,
'Quantity': 1,
# 'MaterialId':item.P
})
return json.JSONEncoder().encode(res)
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_Work_Info error:%s' % e)
return json.JSONEncoder().encode(res)