From 1b490951b1ac211e28e2fd1d9dbb6f662b06982a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 15 Jan 2024 17:31:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E4=BC=A0=E9=80=92=E5=B7=A5=E5=8D=95=E5=8F=B7=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B7=A5=E5=8D=95=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__init__.py | 1 + sf_manufacturing/controllers/__init__.py | 1 + sf_manufacturing/controllers/controllers.py | 40 +++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 sf_manufacturing/controllers/__init__.py create mode 100644 sf_manufacturing/controllers/controllers.py diff --git a/sf_manufacturing/__init__.py b/sf_manufacturing/__init__.py index 0650744f..f7209b17 100644 --- a/sf_manufacturing/__init__.py +++ b/sf_manufacturing/__init__.py @@ -1 +1,2 @@ from . import models +from . import controllers diff --git a/sf_manufacturing/controllers/__init__.py b/sf_manufacturing/controllers/__init__.py new file mode 100644 index 00000000..e046e49f --- /dev/null +++ b/sf_manufacturing/controllers/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py new file mode 100644 index 00000000..08bcbfa4 --- /dev/null +++ b/sf_manufacturing/controllers/controllers.py @@ -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) From 22176eda6968d97e6d4ff9305a3a3b59c64a8447 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 16 Jan 2024 11:00:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 08bcbfa4..c4fd6b87 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -31,10 +31,12 @@ class Manufacturing_Connect(http.Controller): 'ProductionLine': item.production_line, 'CraftName': item.name, 'Quantity': 1, - # 'MaterialId':item.P + 'MaterialId': item.product_id.default_code, + 'MaterialName': item.product_id.name, + # 'Spec':item.mat, + 'Material': item.materials_type_id.name }) - 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) + return json.JSONEncoder().encode(res)