Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
This commit is contained in:
@@ -22,7 +22,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
# ret = json.loads(ret['result'])
|
# ret = json.loads(ret['result'])
|
||||||
logging.info('DeviceId:%s' % ret)
|
logging.info('DeviceId:%s' % ret)
|
||||||
tool_groups = request.env['sf.tool.groups'].sudo().search([])
|
tool_groups = request.env['sf.tool.groups'].sudo().search([('active', '=', True)])
|
||||||
|
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
if tool_groups:
|
if tool_groups:
|
||||||
|
|||||||
@@ -255,30 +255,31 @@ class ToolGroups(models.Model):
|
|||||||
remark = fields.Char('备注', size=50)
|
remark = fields.Char('备注', size=50)
|
||||||
|
|
||||||
# ==========机床刀具组接口==========
|
# ==========机床刀具组接口==========
|
||||||
def _register_tool_groups(self, obj):
|
# def _register_tool_groups(self, obj):
|
||||||
create_url = '/AutoDeviceApi/MachineToolGroup'
|
# # create_url = '/AutoDeviceApi/MachineToolGroup'
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
# token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(obj, token, sf_secret_key)
|
# headers = Common.get_headers(obj, token, sf_secret_key)
|
||||||
strurl = sf_sync_config['sf_url'] + create_url
|
# strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/MachineToolGroup"
|
||||||
device_id = ''
|
# device_id = ''
|
||||||
name = None
|
# name = None
|
||||||
if obj:
|
# if obj:
|
||||||
for equipment_id in obj.equipment_ids:
|
# for equipment_id in obj.equipment_ids:
|
||||||
device_id = '%s,%s' % (device_id, equipment_id.name)
|
# device_id = '%s,%s' % (device_id, equipment_id.name)
|
||||||
name = obj.name
|
# name = obj.name
|
||||||
val = {
|
# val = {
|
||||||
'DeviceId': device_id,
|
# 'DeviceId': device_id,
|
||||||
'GroupName': name,
|
# 'GroupName': name,
|
||||||
}
|
# }
|
||||||
kw = json.dumps(val, ensure_ascii=False)
|
# kw = json.dumps(val, ensure_ascii=False)
|
||||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
# print(r)
|
||||||
if r == 200:
|
# ret = r.json()
|
||||||
return "机床刀具组发送成功"
|
# if r == 200:
|
||||||
else:
|
# return "机床刀具组发送成功"
|
||||||
raise ValidationError("机床刀具组发送失败")
|
# else:
|
||||||
|
# raise ValidationError("机床刀具组发送失败")
|
||||||
|
|
||||||
# def write(self, vals):
|
# def write(self, vals):
|
||||||
# obj = super().write(vals)
|
# obj = super().write(vals)
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class Http(models.AbstractModel):
|
|||||||
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
|
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
|
||||||
# raise AuthenticationError('请求已过期')
|
# raise AuthenticationError('请求已过期')
|
||||||
post_time = int(datas['HTTP_TIMESTAMP'])
|
post_time = int(datas['HTTP_TIMESTAMP'])
|
||||||
|
_logger.info('HTTP_TIMESTAMP:%s' % post_time)
|
||||||
|
_logger.info('HTTP_CHECKSTR:%s' % datas['HTTP_CHECKSTR'])
|
||||||
datetime_post = datetime.fromtimestamp(post_time)
|
datetime_post = datetime.fromtimestamp(post_time)
|
||||||
datetime_now = datetime.now().replace(microsecond=0)
|
datetime_now = datetime.now().replace(microsecond=0)
|
||||||
datetime_del = datetime_now + timedelta(seconds=5)
|
datetime_del = datetime_now + timedelta(seconds=5)
|
||||||
@@ -42,7 +44,8 @@ class Http(models.AbstractModel):
|
|||||||
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
||||||
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
_logger.info('check_str:%s' % check_sf_str)
|
_logger.info('check_str:%s' % check_sf_str)
|
||||||
if check_sf_str != datas['HTTP_CHECKSTR']:
|
_logger.info('check_sf_str:%s' % check_sf_str)
|
||||||
raise AuthenticationError('数据校验不通过')
|
# if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
|
# raise AuthenticationError('数据校验不通过')
|
||||||
else:
|
else:
|
||||||
raise AuthenticationError('请求参数中无token')
|
raise AuthenticationError('请求参数中无token')
|
||||||
|
|||||||
@@ -21,27 +21,32 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
logging.info('RfidCode:%s' % ret['RfidCode'])
|
logging.info('RfidCode:%s' % ret['RfidCode'])
|
||||||
workorder = request.env['mrp.workorder'].sudo().search(
|
if 'RfidCode' in ret:
|
||||||
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
|
workorder = request.env['mrp.workorder'].sudo().search(
|
||||||
if workorder:
|
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
|
||||||
for item in workorder:
|
if workorder:
|
||||||
res['Datas'].append({
|
for item in workorder:
|
||||||
'BillId': item.production_id.name,
|
res['Datas'].append({
|
||||||
'ProductionLine': item.production_line,
|
'BillId': item.production_id.name,
|
||||||
'CraftName': item.name,
|
'ProductionLine': item.production_id.production_line_id.id,
|
||||||
'Quantity': 1,
|
'CraftName': item.name,
|
||||||
'MaterialId': item.product_id.default_code,
|
'Quantity': 1,
|
||||||
'MaterialName': item.product_id.name,
|
'MaterialId': item.product_id.default_code,
|
||||||
'Spec': '%s×%s×%s' % (item.move_raw_ids.materiel_length, item.move_raw_ids.materiel_width,
|
'MaterialName': item.product_id.name,
|
||||||
item.move_raw_ids.materiel_height),
|
'Spec': '%s×%s×%s' % (item.move_raw_ids.materiel_length, item.move_raw_ids.materiel_width,
|
||||||
'Material': item.product_id.materials_type_id.name
|
item.move_raw_ids.materiel_height),
|
||||||
})
|
'Material': item.product_id.materials_type_id.name
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工单'}
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('get_Work_Info error:%s' % e)
|
logging.info('get_Work_Info error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/GetShiftPlan', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/GetShiftPlan', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def get_ShiftPlan(self, **kw):
|
def get_ShiftPlan(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -54,9 +59,12 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
if 'ProductionLine' in ret:
|
||||||
|
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
|
||||||
|
else:
|
||||||
|
ProductionLine = False
|
||||||
|
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
|
||||||
logging.info('RfidCode:%s' % ret)
|
logging.info('RfidCode:%s' % ret)
|
||||||
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['ProductionLine'])])
|
|
||||||
if workorder:
|
if workorder:
|
||||||
for item in workorder:
|
for item in workorder:
|
||||||
date_planned_start = ''
|
date_planned_start = ''
|
||||||
@@ -99,17 +107,24 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
logging.info('RfidCode:%s' % ret['RfidCode'])
|
||||||
logging.info('RfidCode:%s' % ret)
|
if 'RfidCode' in ret:
|
||||||
workorder = request.env['mrp.workorder'].sudo().search([('routing_type', '=', '前置三元定位检测')])
|
workorder = request.env['mrp.workorder'].sudo().search(
|
||||||
if workorder:
|
[('routing_type', '=', '前置三元定位检测'), ('rfid_code', '=', ret['RfidCode'])])
|
||||||
for item in workorder:
|
if workorder:
|
||||||
res['Datas'].append({
|
for item in workorder:
|
||||||
'XOffset': item.production_id.name,
|
if item.material_center_point:
|
||||||
'YOffset': item.RfidCode,
|
offset = item.material_center_point.strip('()').split(',')
|
||||||
'ZOffet': item.name,
|
res['Datas'].append({
|
||||||
'COffset': 1
|
'XOffset': 0 if not item.material_center_point else offset[0],
|
||||||
})
|
'YOffset': 0 if not item.material_center_point else offset[1],
|
||||||
|
'ZOffet': 0 if not item.material_center_point else offset[3],
|
||||||
|
'COffset': 'G54' if not item.X_deviation_angle else item.X_deviation_angle
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('get_qcCheck error:%s' % e)
|
logging.info('get_qcCheck error:%s' % e)
|
||||||
@@ -187,13 +202,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
|
|
||||||
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def Workorder_QcCheck(self, **kw):
|
def PartQualityInspect(self, **kw):
|
||||||
"""
|
"""
|
||||||
零件质检
|
零件质检
|
||||||
:param kw:
|
:param kw:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
logging.info('Workorder_QcCheck:%s' % kw)
|
logging.info('PartQualityInspect:%s' % kw)
|
||||||
try:
|
try:
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
@@ -219,7 +234,46 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('Workorder_QcCheck error:%s' % e)
|
logging.info('PartQualityInspect error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
@http.route('/AutoDeviceApi/NCProgDolod', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def NCProgDolod(self, **kw):
|
||||||
|
"""
|
||||||
|
中控系统传递RFID编号给MES,获取程序单及程序文件。Ftp下载文件
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('NCProgDolod:%s' % kw)
|
||||||
|
try:
|
||||||
|
res = {'Succeed': True, 'Datas': []}
|
||||||
|
datas = request.httprequest.data
|
||||||
|
ret = json.loads(datas)
|
||||||
|
if 'RfidCode' in ret:
|
||||||
|
logging.info('RfidCode:%s' % ret['RfidCode'])
|
||||||
|
workorder = request.env['mrp.workorder'].sudo().search(
|
||||||
|
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', 'CNC加工')])
|
||||||
|
if workorder:
|
||||||
|
for item in workorder.cnc_ids:
|
||||||
|
res['Datas'].append({
|
||||||
|
'CraftId': workorder.id,
|
||||||
|
'CraftName': workorder.name,
|
||||||
|
'SortId': item.sequence_number,
|
||||||
|
'ProgramName': item.program_name,
|
||||||
|
'ToolId': item.cutting_tool_no,
|
||||||
|
'ToolName': item.cutting_tool_name,
|
||||||
|
'Depth': item.depth_of_processing_z,
|
||||||
|
'ProgramPath': item.program_path,
|
||||||
|
'ProgramTime': item.estimated_processing_time,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '暂无工单及对应的CNC程序数据'}
|
||||||
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('NCProgDolod error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
from datetime import datetime
|
from datetime import date
|
||||||
|
from datetime import datetime, timedelta
|
||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
import math
|
import math
|
||||||
@@ -129,12 +130,30 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
total_wight = fields.Float(string="总重量")
|
total_wight = fields.Float(string="总重量")
|
||||||
maximum_carrying_weight = fields.Char(string="最大承载重量[kg]")
|
maximum_carrying_weight = fields.Char(string="最大承载重量[kg]")
|
||||||
maximum_clamping_force = fields.Char(string="最大夹持力[n]")
|
maximum_clamping_force = fields.Char(string="最大夹持力[n]")
|
||||||
production_line = fields.Char(string="生产线")
|
production_line_id = fields.Many2one('sf.production.line', string="生产线")
|
||||||
preset_program_information = fields.Char(string="预调程序信息")
|
preset_program_information = fields.Char(string="预调程序信息")
|
||||||
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
|
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
|
||||||
is_delivery = fields.Boolean('是否配送完成', default=False)
|
is_delivery = fields.Boolean('是否配送完成', default=False)
|
||||||
rfid_code = fields.Char('RFID')
|
rfid_code = fields.Char('RFID')
|
||||||
|
|
||||||
|
def get_plan_workorder(self, production_line):
|
||||||
|
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
|
||||||
|
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')
|
||||||
|
"""
|
||||||
|
params = [tomorrow, tomorrow, tomorrow, tomorrow]
|
||||||
|
if production_line:
|
||||||
|
sql += "AND production_line_id = %s"
|
||||||
|
params.append(production_line)
|
||||||
|
self.env.cr.execute(sql, params)
|
||||||
|
ids = [t[0] for t in self.env.cr.fetchall()]
|
||||||
|
return [('id', 'in', ids)]
|
||||||
|
|
||||||
@api.onchange('is_ok')
|
@api.onchange('is_ok')
|
||||||
def _onchange_inspection_user_id(self):
|
def _onchange_inspection_user_id(self):
|
||||||
"""
|
"""
|
||||||
@@ -626,10 +645,12 @@ class CNCprocessing(models.Model):
|
|||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||||
production_id = fields.Many2one('mrp.production', string="制造订单")
|
production_id = fields.Many2one('mrp.production', string="制造订单")
|
||||||
button_state = fields.Boolean(string='是否已经下发')
|
button_state = fields.Boolean(string='是否已经下发')
|
||||||
|
program_path = fields.Char('程序文件路径')
|
||||||
|
|
||||||
# mrs下发编程单创建CNC加工
|
# mrs下发编程单创建CNC加工
|
||||||
def cnc_processing_create(self, cnc_workorder, ret):
|
def cnc_processing_create(self, cnc_workorder, ret, program_path_ftp):
|
||||||
logging.info('ret:%s' % ret)
|
logging.info('ret:%s' % ret)
|
||||||
|
logging.info('program_path_ftp:%s' % program_path_ftp)
|
||||||
for obj in ret['programming_list']:
|
for obj in ret['programming_list']:
|
||||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
|
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
|
||||||
('processing_panel', '=', obj['processing_panel']),
|
('processing_panel', '=', obj['processing_panel']),
|
||||||
@@ -649,7 +670,8 @@ class CNCprocessing(models.Model):
|
|||||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
||||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||||
'estimated_processing_time': obj['estimated_processing_time'],
|
'estimated_processing_time': obj['estimated_processing_time'],
|
||||||
'remark': obj['remark']
|
'remark': obj['remark'],
|
||||||
|
'program_path': '%s/%s' % (program_path_ftp, obj['program_name'])
|
||||||
})
|
})
|
||||||
cnc_processing.get_cnc_processing_file(ret['folder_name'], cnc_processing, workorder.processing_panel)
|
cnc_processing.get_cnc_processing_file(ret['folder_name'], cnc_processing, workorder.processing_panel)
|
||||||
# cnc_workorder.state = 'done'
|
# cnc_workorder.state = 'done'
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
from odoo import http
|
from odoo import http
|
||||||
@@ -42,8 +43,10 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
logging.info('创建cnc工单')
|
logging.info('创建cnc工单')
|
||||||
|
program_path_ftp = os.path.join('/', ret['folder_name'], 'return', r)
|
||||||
|
logging.info('cnc程序路径 :%s' % program_path_ftp)
|
||||||
request.env['sf.cnc.processing'].with_user(
|
request.env['sf.cnc.processing'].with_user(
|
||||||
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret)
|
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path_ftp)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
else:
|
else:
|
||||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
# ret = json.loads(ret['result'])
|
# ret = json.loads(ret['result'])
|
||||||
logging.info('DeviceId:%s' % ret)
|
logging.info('DeviceId:%s' % ret)
|
||||||
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([])
|
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([('active', '=', True)])
|
||||||
|
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
if functional_tools:
|
if functional_tools:
|
||||||
|
|||||||
@@ -179,25 +179,25 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
# ==========刀具组接口==========
|
# ==========刀具组接口==========
|
||||||
def _register_functional_tool_groups(self, obj):
|
# def _register_functional_tool_groups(self, obj):
|
||||||
create_url = '/AutoDeviceApi/ToolGroup'
|
# create_url = '/AutoDeviceApi/ToolGroup'
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
# token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(obj, token, sf_secret_key)
|
# headers = Common.get_headers(obj, token, sf_secret_key)
|
||||||
strurl = sf_sync_config['sf_url'] + create_url
|
# strurl = sf_sync_config['sf_url'] + create_url
|
||||||
val = {
|
# val = {
|
||||||
'ToolName': obj.name,
|
# 'ToolName': obj.name,
|
||||||
'GroupName': obj.tool_groups_id.name,
|
# 'GroupName': obj.tool_groups_id.name,
|
||||||
'ToolId': obj.code
|
# 'ToolId': obj.code
|
||||||
}
|
# }
|
||||||
kw = json.dumps(val, ensure_ascii=False)
|
# kw = json.dumps(val, ensure_ascii=False)
|
||||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
ret = r.json()
|
# ret = r.json()
|
||||||
if r == 200:
|
# if r == 200:
|
||||||
return "刀具组发送成功"
|
# return "刀具组发送成功"
|
||||||
else:
|
# else:
|
||||||
raise ValidationError("刀具组发送失败")
|
# raise ValidationError("刀具组发送失败")
|
||||||
|
|
||||||
# @api.model_create_multi
|
# @api.model_create_multi
|
||||||
# def create(self, vals):
|
# def create(self, vals):
|
||||||
|
|||||||
Reference in New Issue
Block a user