1、优化机床模型的标准刀库对象,删除了制造模块中机床刀位模型大部分字段,在刀具管理模块中通过继承机床刀位模型新增字段,同时前端机床from视图中的刀位的tree视图新增大量字段;2、刀具管理模块新增controllers模块文件,新增机床当前刀库实时信息接口。
This commit is contained in:
@@ -870,6 +870,11 @@ class SfMaintenanceEquipmentTool(models.Model):
|
|||||||
_description = '机床刀位'
|
_description = '机床刀位'
|
||||||
|
|
||||||
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
||||||
|
|
||||||
|
code = fields.Char('机床刀位号')
|
||||||
|
name = fields.Char('刀位号', compute='_compute_name')
|
||||||
|
|
||||||
|
# 待删除字段
|
||||||
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
|
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
|
||||||
domain="[('categ_type', '=', '刀具')]")
|
domain="[('categ_type', '=', '刀具')]")
|
||||||
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
|
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
|
||||||
@@ -882,9 +887,6 @@ class SfMaintenanceEquipmentTool(models.Model):
|
|||||||
life_value_max = fields.Char('最大寿命值')
|
life_value_max = fields.Char('最大寿命值')
|
||||||
alarm_value = fields.Char('报警值')
|
alarm_value = fields.Char('报警值')
|
||||||
used_value = fields.Char('已使用值')
|
used_value = fields.Char('已使用值')
|
||||||
code = fields.Char('机床刀位号')
|
|
||||||
|
|
||||||
name = fields.Char('', compute='_compute_name')
|
|
||||||
|
|
||||||
@api.depends('code')
|
@api.depends('code')
|
||||||
def _compute_name(self):
|
def _compute_name(self):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<!-- 设备增加刀具库位table-->
|
设备增加刀具库位table
|
||||||
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
|
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
|
||||||
<field name="name">sf_manufacturing_equipment.form</field>
|
<field name="name">sf_manufacturing_equipment.form</field>
|
||||||
<field name="model">maintenance.equipment</field>
|
<field name="model">maintenance.equipment</field>
|
||||||
@@ -13,17 +13,6 @@
|
|||||||
<field name = 'product_template_ids' >
|
<field name = 'product_template_ids' >
|
||||||
<tree editable='bottom'>
|
<tree editable='bottom'>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="product_template_id"/>
|
|
||||||
<field name="image_1920" widget="image"/>
|
|
||||||
<field name="categ_type"/>
|
|
||||||
<field name="diameter"/>
|
|
||||||
<field name="precision"/>
|
|
||||||
<field name="tool_code"/>
|
|
||||||
<field name="hilt_name"/>
|
|
||||||
<field name="hilt_code"/>
|
|
||||||
<field name="life_value_max"/>
|
|
||||||
<field name="alarm_value"/>
|
|
||||||
<field name="used_value"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# -*-coding:utf-8-*-
|
# -*-coding:utf-8-*-
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizard
|
from . import wizard
|
||||||
|
from . import controllers
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'wizard/wizard_view.xml',
|
'wizard/wizard_view.xml',
|
||||||
'views/tool_base_views.xml',
|
'views/tool_base_views.xml',
|
||||||
|
'views/sf_maintenance_equipment.xml',
|
||||||
'views/menu_view.xml',
|
'views/menu_view.xml',
|
||||||
'views/tool_material_search.xml',
|
'views/tool_material_search.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
1
sf_tool_management/controllers/__init__.py
Normal file
1
sf_tool_management/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import controllers
|
||||||
56
sf_tool_management/controllers/controllers.py
Normal file
56
sf_tool_management/controllers/controllers.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# -*- 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/FeedBackOut', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_equipment_tool_Info(self, **kw):
|
||||||
|
"""
|
||||||
|
机床当前刀库实时信息
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('get_equipment_tool_Info:%s' % kw)
|
||||||
|
try:
|
||||||
|
datas = request.httprequest.data
|
||||||
|
ret = json.loads(datas)
|
||||||
|
ret = json.loads(ret['result'])
|
||||||
|
logging.info('DeviceId:%s' % ret)
|
||||||
|
equipment = request.env['maintenance.equipment'].sudo().search([('name', '=', ret['DeviceId'])])
|
||||||
|
|
||||||
|
res = {'Succeed': True, 'Datas': []}
|
||||||
|
if equipment:
|
||||||
|
for item in equipment:
|
||||||
|
data = []
|
||||||
|
for equipment_tool_id in item.product_template_ids:
|
||||||
|
functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||||
|
[('code', '=', equipment_tool_id.tool_code)])
|
||||||
|
alarm_time = None
|
||||||
|
if functional_tool_id.functional_tool_status == '报警':
|
||||||
|
alarm_time = self.env['sf.functional.tool.warning'].sudo().search(
|
||||||
|
[('code', '=', equipment_tool_id.tool_code)]).alarm_time
|
||||||
|
equipment_tool = {
|
||||||
|
'RfidCode': None,
|
||||||
|
'ToolId': equipment_tool_id.code,
|
||||||
|
'ToolName': equipment_tool_id.functional_tool_name_id.name,
|
||||||
|
'MaxLife': equipment_tool_id.life_value_max,
|
||||||
|
'UseLife': equipment_tool_id.used_value,
|
||||||
|
'AddDatetime': equipment_tool_id.tool_install_time,
|
||||||
|
'State': functional_tool_id.functional_tool_status,
|
||||||
|
'WarnDate': alarm_time if alarm_time else False
|
||||||
|
}
|
||||||
|
data.append(equipment_tool)
|
||||||
|
res['Datas'].append({
|
||||||
|
'DeviceId': item.name,
|
||||||
|
'Data': data
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('get_equipment_tool_Info error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
@@ -1,9 +1,22 @@
|
|||||||
from odoo import models, api
|
from odoo import models, api, fields
|
||||||
|
|
||||||
|
|
||||||
class SfMaintenanceEquipmentTool(models.Model):
|
class SfMaintenanceEquipmentTool(models.Model):
|
||||||
_inherit = 'maintenance.equipment.tool'
|
_inherit = 'maintenance.equipment.tool'
|
||||||
|
|
||||||
|
functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具名称')
|
||||||
|
|
||||||
|
image = fields.Binary('图片', related='functional_tool_name_id.image')
|
||||||
|
tool_code = fields.Char('功能刀具编码', related='functional_tool_name_id.code')
|
||||||
|
functional_tool_type = fields.Char('功能刀具类型', related='functional_tool_name_id.sf_cutting_tool_type_id.name')
|
||||||
|
tool_groups = fields.Char('刀具组', related='functional_tool_name_id.tool_groups_id.name')
|
||||||
|
diameter = fields.Integer('直径(mm)', related='functional_tool_name_id.functional_tool_diameter')
|
||||||
|
knife_tip_r_angle = fields.Float('刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle')
|
||||||
|
life_value_max = fields.Integer('最大寿命值(min)', related='functional_tool_name_id.max_lifetime_value')
|
||||||
|
alarm_value = fields.Integer('报警值(min)', related='functional_tool_name_id.alarm_value')
|
||||||
|
used_value = fields.Integer('已使用值(min)', related='functional_tool_name_id.used_value')
|
||||||
|
tool_install_time = fields.Datetime('机内装刀时间')
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
tools = super().create(vals_list)
|
tools = super().create(vals_list)
|
||||||
|
|||||||
32
sf_tool_management/views/sf_maintenance_equipment.xml
Normal file
32
sf_tool_management/views/sf_maintenance_equipment.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<!-- 设备增加刀具库位table-->
|
||||||
|
<record id="sf_maintenance_equipment_tool_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">sf_manufacturing_equipment.form</field>
|
||||||
|
<field name="model">maintenance.equipment</field>
|
||||||
|
<field name="inherit_id" ref="sf_manufacturing.sf_manufacturing_hr_equipment_view_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[@name='sf_equipment_product_template']" position="replace">
|
||||||
|
<page string="标准刀库" name="sf_equipment_product_template"
|
||||||
|
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
||||||
|
<field name='product_template_ids'>
|
||||||
|
<tree editable='bottom'>
|
||||||
|
<field name="code"/>
|
||||||
|
<field name="tool_code"/>
|
||||||
|
<field name="functional_tool_type"/>
|
||||||
|
<field name="functional_tool_name_id"/>
|
||||||
|
<field name="image" widget="image"/>
|
||||||
|
<field name="tool_groups"/>
|
||||||
|
<field name="diameter"/>
|
||||||
|
<field name="knife_tip_r_angle"/>
|
||||||
|
<field name="life_value_max"/>
|
||||||
|
<field name="alarm_value"/>
|
||||||
|
<field name="used_value"/>
|
||||||
|
<field name="tool_install_time"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -41,7 +41,7 @@ class ToolChangeRequirementInformation(models.TransientModel):
|
|||||||
replacement_tool_setting_length = fields.Float(string='待换刀具总长度(mm)', required=True)
|
replacement_tool_setting_length = fields.Float(string='待换刀具总长度(mm)', required=True)
|
||||||
replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)')
|
replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)')
|
||||||
replacement_effective_length = fields.Float(string='待换刀具有效长(mm)')
|
replacement_effective_length = fields.Float(string='待换刀具有效长(mm)')
|
||||||
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], requirded=True,
|
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], required=True,
|
||||||
string='待换刀具粗/中/精', default='3')
|
string='待换刀具粗/中/精', default='3')
|
||||||
|
|
||||||
replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)')
|
replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)')
|
||||||
|
|||||||
Reference in New Issue
Block a user