49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import json
|
||
import requests
|
||
import logging
|
||
from odoo import fields, models, api
|
||
from odoo.exceptions import ValidationError
|
||
from odoo.addons.sf_base.commons.common import Common
|
||
|
||
|
||
class CNCprocessing(models.Model):
|
||
_inherit = 'sf.cnc.processing'
|
||
_description = 'CNC加工用刀检测'
|
||
|
||
# ==========MES装刀指令接口==========
|
||
# def register_cnc_processing(self, knife_plan):
|
||
# config = self.env['res.config.settings'].get_values()
|
||
# # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||
# headers = {'Authorization': config['center_control_Authorization']}
|
||
# crea_url = config['center_control_url'] + "/AutoDeviceApi/ToolLoadInstruct"
|
||
# val = {
|
||
# 'DeviceId': knife_plan.machine_table_name,
|
||
# 'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid.zfill(10),
|
||
# 'ToolId': int(knife_plan.cam_cutter_spacing_code[1:])
|
||
# }
|
||
# r = requests.post(crea_url, json=val, headers=headers)
|
||
# ret = r.json()
|
||
# logging.info('register_cnc_processing:%s' % ret)
|
||
# if ret['Succeed']:
|
||
# return "MES装刀指令发送成功"
|
||
# else:
|
||
# raise ValidationError("MES装刀指令发送失败")
|
||
|
||
@api.model_create_multi
|
||
def create(self, vals):
|
||
obj = super(CNCprocessing, self).create(vals)
|
||
for item in obj:
|
||
# 调用CAM工单程序用刀计划创建方法
|
||
self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(item)
|
||
logging.info('成功调用CAM工单程序用刀计划创建方法!!!')
|
||
return obj
|
||
|
||
|
||
class MrpWorkCenter(models.Model):
|
||
_inherit = 'mrp.workcenter'
|
||
|
||
def action_tool_order(self):
|
||
action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act')
|
||
result = action.read()[0]
|
||
return result
|