新增同步cloud的刀具标准库接口
This commit is contained in:
@@ -410,17 +410,25 @@ class ResProductMo(models.Model):
|
||||
|
||||
@api.onchange('cutting_tool_material_id')
|
||||
def _onchange_cutting_tool_material_id(self):
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json={}, data=res, headers=headers)
|
||||
result = result.json()
|
||||
if result['status'] == 1:
|
||||
self.cutting_tool_model = result['data']
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
if self.cutting_tool_material_id:
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json={}, data=res, headers=headers)
|
||||
result = result.json()
|
||||
if result['status'] == 1:
|
||||
data = result['data']
|
||||
model_ids = []
|
||||
for item in data:
|
||||
model_ids.append((0, 0, {
|
||||
'name': item['name']
|
||||
}))
|
||||
self.cutting_tool_model = model_ids
|
||||
return {}
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
|
||||
@api.depends('cutting_tool_material_id')
|
||||
def _get_cutting_tool_model(self):
|
||||
@@ -888,7 +896,8 @@ class SfMaintenanceEquipmentTool(models.Model):
|
||||
_description = '机床刀位'
|
||||
|
||||
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
||||
product_template_id = fields.Many2one('product.template', string='功能刀具名称', domain="[('categ_type', '=', '刀具')]")
|
||||
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
|
||||
domain="[('categ_type', '=', '刀具')]")
|
||||
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
|
||||
categ_type = fields.Char(string='功能刀具类型')
|
||||
diameter = fields.Char('直径')
|
||||
@@ -900,4 +909,3 @@ class SfMaintenanceEquipmentTool(models.Model):
|
||||
alarm_value = fields.Char('报警值')
|
||||
used_value = fields.Char('已使用值')
|
||||
code = fields.Char('机床刀位号')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user