对功能刀具预警、实时分布和出入库记录的代码进行了合并优化

This commit is contained in:
yuxianghui
2023-06-14 16:27:16 +08:00
parent 3236d477c0
commit 24fd92fa3b
12 changed files with 259 additions and 335 deletions

View File

@@ -1,2 +1,2 @@
# -*-coding:utf-8-*- # -*-coding:utf-8-*-
from . import models from . import models

View File

@@ -12,10 +12,9 @@
'website': 'https://www.sf.jikimo.com', 'website': 'https://www.sf.jikimo.com',
'depends': ['account', 'sf_base', 'mrp'], 'depends': ['account', 'sf_base', 'mrp'],
'data': [ 'data': [
'security/group_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/tool_base_views.xml',
'views/functional_tool_real_time_distribution_view.xml',
'views/function_tool_entry_exit_records_view.xml',
'views/menu_view.xml', 'views/menu_view.xml',
], ],

View File

@@ -1,4 +1,2 @@
from . import base from . import base
from . import functional_tool_real_time_distribution
from . import function_tool_entry_exit_records

View File

@@ -1,3 +1,76 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import fields, models, api
class FunctionalCuttingToolEntity(models.Model):
_name = 'sf.functional.cutting.tool.entity'
_inherit = 'sf.functional.cutting.tool'
_description = '功能刀具管理'
order = fields.Char(string='')
# 功能刀具预警 特有字段
install_tool_time = fields.Char("装刀时间")
outbound_time = fields.Char('出库时间')
on_board_time = fields.Char('上机时间')
machine_tool_code = fields.Char('机台号')
cutting_tool_code = fields.Char('刀位号')
idle_time = fields.Char('闲置时长')
alarm_value = fields.Char('报警值')
used_value = fields.Char('已使用值')
alarm_type = fields.Char('报警类型')
alarm_time = fields.Char('报警时间')
dispose_user = fields.Char('处理人')
dispose_time = fields.Char('处理时间')
dispose_func = fields.Char('处理方法/措施')
remark = fields.Char('备注')
# 功能刀具出入库记录 特有字段
thickness = fields.Selection([('1', ''), ('2', ''), ('3', '')], string='粗/中/细')
max_life_span = fields.Char(string='最大寿命值')
# alarm_value = fields.Char(string='报警值')
# used_value = fields.Char(string='已使用值')
current_state = fields.Char(string='当前状态')
current_store_area = fields.Char(string='当前库区')
current_store_place = fields.Char(string='当前库位')
number = fields.Integer(string='数量')
reason_application = fields.Char(string='申请原因')
applicant = fields.Char(string='申请人')
return_staff = fields.Char(string='归还人')
return_time = fields.Date(string='归还入库时间')
tool_state = fields.Char(string="刀具状态")
tool_install_staff = fields.Char(string='装刀人')
tool_install_time = fields.Datetime(string='装刀时间')
receive_equipment = fields.Char(string='领用机台')
receive_staff = fields.Char(string='领用人')
receive_time = fields.Char(string='领用出库时间')
# remark = fields.Text(string='备注/说明')
# 功能刀具实时分布
tool_stock_num = fields.Text(string='刀具房库存数量')
side_shelf_num = fields.Text(string='线边货架货架数量')
on_tool_stock_num = fields.Text(string='机内刀库库存数量')
tool_stock_total = fields.Text(string='合计')
return_reuse_num_re = fields.Text(string='归还再用数量(精)')
return_reuse_num_co = fields.Text(string='归还再用数量(粗)')
return_processing_num = fields.Text(string='归还需磨削数量')
return_total = fields.Text(string='合计')
total = fields.Text(string='总计')
# remark = fields.Text(string='备注/说明')
@api.model
def create(self, vals):
if not vals.get('order'):
vals['order'] = self._generate_code()
return super(FunctionalCuttingToolEntity, self).create(vals)
@api.model
def _generate_code(self):
last_tool = self.search([], order='id desc', limit=1)
if last_tool:
last_code = int(last_tool.code.split('-')[-1])
new_code = '{:03d}'.format(last_code + 1)
else:
new_code = '001'
return new_code

View File

@@ -1,47 +0,0 @@
from odoo import models,fields,api
class FunctionToolEntryExitRecords(models.Model):
_name = 'sf.function.tool.entry.exit.records'
_description = '功能刀具出入库记录'
_inherit = 'sf.functional.cutting.tool'
order = fields.Char(string='')
thickness = fields.Selection([('1', ''), ('2', ''), ('3', '')], string='粗/中/细')
max_life_span = fields.Char(string='最大寿命值')
alarm_value = fields.Char(string='报警值')
used_value = fields.Char(string='已使用值')
current_state = fields.Char(string='当前状态')
current_store_area = fields.Char(string='当前库区')
current_store_place = fields.Char(string='当前库位')
number = fields.Integer(string='数量')
reason_application = fields.Char(string='申请原因')
applicant = fields.Char(string='申请人')
return_staff = fields.Char(string='归还人')
return_time = fields.Date(string='归还入库时间')
tool_state = fields.Char(string="刀具状态")
tool_install_staff = fields.Char(string='装刀人')
tool_install_time = fields.Datetime(string='装刀时间')
receive_equipment = fields.Char(string='领用机台')
receive_staff = fields.Char(string='领用人')
receive_time = fields.Char(string='领用出库时间')
remark = fields.Text(string='备注/说明')
@api.model
def create(self, vals):
if not vals.get('order'):
vals['order'] = self._generate_code()
return super(FunctionToolEntryExitRecords, self).create(vals)
@api.model
def _generate_code(self):
last_tool = self.search([], order='id desc', limit=1)
if last_tool:
last_code = int(last_tool.code.split('-')[-1])
new_code = '{:03d}'.format(last_code + 1)
else:
new_code = '001'
return new_code

View File

@@ -1,38 +0,0 @@
from odoo import fields, models,api
class FunctionalToolRealTimeDistribution(models.Model):
_name = 'sf.functional.tool.real.time.distribution'
_description = "功能刀具实时分布"
_inherit = 'sf.functional.cutting.tool'
order = fields.Char(string='')
tool_stock_num = fields.Text(string='刀具房库存数量')
side_shelf_num = fields.Text(string='线边货架货架数量')
on_tool_stock_num = fields.Text(string='机内刀库库存数量')
tool_stock_total = fields.Text(string='合计')
return_reuse_num_re = fields.Text(string='归还再用数量(精)')
return_reuse_num_co = fields.Text(string='归还再用数量(粗)')
return_processing_num = fields.Text(string='归还需磨削数量')
return_total = fields.Text(string='合计')
total = fields.Text(string='总计')
remark = fields.Text(string='备注/说明')
@api.model
def create(self, vals):
if not vals.get('order'):
vals['order'] = self._generate_code()
return super(FunctionalToolRealTimeDistribution, self).create(vals)
@api.model
def _generate_code(self):
last_tool = self.search([], order='id desc', limit=1)
if last_tool:
last_code = int(last_tool.code.split('-')[-1])
new_code = '{:03d}'.format(last_code + 1)
else:
new_code = '001'
return new_code

View File

@@ -0,0 +1,4 @@
<odoo>
<data>
</data>
</odoo>

View File

@@ -1,3 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_functional_tool_real_time_distribution,sf.functional.tool.real.time.distribution,model_sf_functional_tool_real_time_distribution,base.group_user,1,1,1,1 access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1
access_sf_function_tool_entry_exit_records,sf.function.tool.entry.exit.records,model_sf_function_tool_entry_exit_records,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_functional_tool_real_time_distribution access_sf_functional_cutting_tool_entity sf.functional.tool.real.time.distribution sf.functional.cutting.tool.entity model_sf_functional_tool_real_time_distribution model_sf_functional_cutting_tool_entity base.group_user 1 1 1 1
3
4
5
6
7

View File

@@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sf_function_tool_entry_exit_records_view_tree" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">sf.function.tool.entry.exit.records</field>
<field name="arch" type="xml">
<tree>
<field name="order"/>
<field name="code"/>
<field name="name"/>
<field name="functional_model_number"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
<field name="thickness"/>
<field name="max_life_span"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_state"/>
<field name="current_store_area"/>
<field name="current_store_place"/>
<field name="number"/>
<field name="reason_application"/>
<field name="applicant"/>
<field name="return_staff"/>
<field name="return_time"/>
<field name="tool_state"/>
<field name="tool_install_staff"/>
<field name="tool_install_time"/>
<field name="receive_equipment"/>
<field name="receive_staff"/>
<field name="receive_time"/>
<field name="remark"/>
</tree>
</field>
</record>
<record id="sf_function_tool_entry_exit_records_view_form" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">sf.function.tool.entry.exit.records</field>
<field name="arch" type="xml">
<form>
<sheet>
<group string="基础信息">
<group>
<field name="order"/>
<field name="code"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
</group>
<group>
<field name="name"/>
<field name="functional_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
</group>
</group>
<group string="参数">
<group>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
</group>
<group>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
</group>
</group>
<group string="其他">
<group>
<field name="thickness"/>
<field name="max_life_span"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_state"/>
<field name="current_store_area"/>
<field name="current_store_place"/>
<field name="number"/>
<field name="reason_application"/>
<field name="remark"/>
</group>
<group>
<field name="applicant"/>
<field name="return_staff"/>
<field name="return_time"/>
<field name="tool_state"/>
<field name="tool_install_staff"/>
<field name="tool_install_time"/>
<field name="receive_equipment"/>
<field name="receive_staff"/>
<field name="receive_time"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_function_tool_entry_exit_records_view_act" model="ir.actions.act_window">
<field name="name">功能刀具出入库记录</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.function.tool.entry.exit.records</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>

View File

@@ -1,109 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sf_functional_tool_real_time_distribution_view_tree" model="ir.ui.view">
<field name="name">功能刀具实时分布</field>
<field name="model">sf.functional.tool.real.time.distribution</field>
<field name="arch" type="xml">
<tree>
<field name="order"/>
<field name="code"/>
<field name="name"/>
<field name="functional_model_number"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="return_reuse_num_re"/>
<field name="return_reuse_num_co"/>
<field name="return_processing_num"/>
<field name="return_total"/>
<field name="total"/>
<field name="remark"/>
</tree>
</field>
</record>
<record id="sf_functional_tool_real_time_distribution_view_form" model="ir.ui.view">
<field name="name">功能刀具实时分布</field>
<field name="model">sf.functional.tool.real.time.distribution</field>
<field name="arch" type="xml">
<form>
<cheet>
<group string="基础信息">
<group>
<field name="order"/>
<field name="code"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
</group>
<group>
<field name="name"/>
<field name="functional_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
</group>
</group>
<group string="参数">
<group>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
</group>
<group>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
</group>
</group>
<group string="其他">
<group>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="total"/>
<field name="remark"/>
</group>
<group>
<field name="return_reuse_num_re"/>
<field name="return_reuse_num_co"/>
<field name="return_processing_num"/>
<field name="return_total"/>
</group>
</group>
</cheet>
</form>
</field>
</record>
<record id="sf_functional_tool_real_time_distribution_view_act" model="ir.actions.act_window">
<field name="name">功能刀具实时分布</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.tool.real.time.distribution</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>

View File

@@ -1,18 +1,37 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<!-- groups="mrp.group_mrp_routings"-->
<record id="action_sf_functional_cutting_tool_warning" model="ir.actions.act_window">
<field name="name">功能刀具预警</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.cutting.tool.entity</field>
<field name="view_mode">tree</field>
</record>
<menuitem id="menu_sf_tool_manage" <menuitem id="menu_sf_tool_manage"
name="刀具管理" name="刀具管理"
groups="mrp.group_mrp_routings"
parent="mrp.menu_mrp_root" parent="mrp.menu_mrp_root"
sequence="20"/> sequence="20"/>
<menuitem <menuitem
sequence="2" id="menu_sf_functional_cutting_tool"
name="功能刀具"
id="menu_sf_base"
action="sf_base.sf_production_materials"
parent="menu_sf_tool_manage" parent="menu_sf_tool_manage"
/> name="功能刀具列表"
sequence="3"
action="sf_base.action_sf_functional_cutting_tool"
/>
<menuitem
id="menu_sf_functional_cutting_tool_warning"
parent="menu_sf_tool_manage"
name="功能刀具预警"
sequence="3"
action="action_sf_functional_cutting_tool_warning"
/>
<menuitem <menuitem
sequence="6" sequence="6"
@@ -20,7 +39,7 @@
id="menu_sf_functional_tool_real_time_distribution" id="menu_sf_functional_tool_real_time_distribution"
action="sf_functional_tool_real_time_distribution_view_act" action="sf_functional_tool_real_time_distribution_view_act"
parent="menu_sf_tool_manage" parent="menu_sf_tool_manage"
/> />
<menuitem <menuitem
sequence="10" sequence="10"
@@ -28,7 +47,7 @@
id="menu_sf_function_tool_entry_exit_records" id="menu_sf_function_tool_entry_exit_records"
action="sf_function_tool_entry_exit_records_view_act" action="sf_function_tool_entry_exit_records_view_act"
parent="menu_sf_tool_manage" parent="menu_sf_tool_manage"
/> />
</data> </data>
</odoo> </odoo>

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- 功能刀具预警tree view -->
<record id="view_functional_cutting_tool_warning_tree" model="ir.ui.view">
<field name="name">sf.functional.cutting.tool.entity.tree</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<tree string="功能刀具">
<field name="code" />
<field name="name" />
<field name="functional_model_number" />
<field name="integral_model_number"/>
<field name="blade_model_number" optional="hide"/>
<field name="cutterbar_model_number" optional="hide"/>
<field name="cutterpad_model_number" optional="hide"/>
<field name="handle_model_number" optional="hide"/>
<field name="chuck_model_number" optional="hide"/>
<field name="install_tool_time" optional="show"/>
<field name="outbound_time" optional="show"/>
<field name="machining_accuracy" optional="hide"/>
<field name="on_board_time" optional="show"/>
<field name="machine_tool_code" optional="show"/>
<field name="cutting_tool_code" optional="show"/>
<field name="idle_time" optional="show"/>
<field name="alarm_value" optional="show"/>
<field name="used_value" optional="show"/>
<field name="alarm_type" optional="show"/>
<field name="alarm_time" optional="show"/>
<field name="dispose_user" optional="show"/>
<field name="dispose_time" optional="show"/>
<field name="dispose_func" optional="show"/>
<field name="remark" optional="show"/>
</tree>
</field>
</record>
<!-- ========================================功能刀具出入库记录================================================================== -->
<record id="sf_function_tool_entry_exit_records_view_tree" model="ir.ui.view">
<field name="name">功能刀具出入库记录</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<tree>
<field name="order"/>
<field name="code"/>
<field name="name"/>
<field name="functional_model_number"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
<field name="thickness"/>
<field name="max_life_span"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_state"/>
<field name="current_store_area"/>
<field name="current_store_place"/>
<field name="number"/>
<field name="reason_application"/>
<field name="applicant"/>
<field name="return_staff"/>
<field name="return_time"/>
<field name="tool_state"/>
<field name="tool_install_staff"/>
<field name="tool_install_time"/>
<field name="receive_equipment"/>
<field name="receive_staff"/>
<field name="receive_time"/>
<field name="remark"/>
</tree>
</field>
</record>
<record id="sf_function_tool_entry_exit_records_view_act" model="ir.actions.act_window">
<field name="name">功能刀具出入库记录</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.cutting.tool.entity</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="sf_function_tool_entry_exit_records_view_tree"/>
</record>
<!-- =====================================功能刀具实时分布============================================================= -->
<record id="sf_functional_tool_real_time_distribution_view_tree" model="ir.ui.view">
<field name="name">功能刀具实时分布</field>
<field name="model">sf.functional.cutting.tool.entity</field>
<field name="arch" type="xml">
<tree>
<field name="order"/>
<field name="code" width="200"/>
<field name="name"/>
<field name="functional_model_number"/>
<field name="integral_model_number"/>
<field name="blade_model_number"/>
<field name="cutterbar_model_number"/>
<field name="cutterpad_model_number"/>
<field name="handle_model_number"/>
<field name="chuck_model_number"/>
<field name="diameter"/>
<field name="tool_grade"/>
<field name="machining_accuracy"/>
<field name="tool_length"/>
<field name="blade_number"/>
<field name="integral_blade_length"/>
<field name="effective_blade_length"/>
<field name="max_life"/>
<field name="is_standard"/>
<field name="applicable_range"/>
<field name="tool_stock_num"/>
<field name="side_shelf_num"/>
<field name="on_tool_stock_num"/>
<field name="tool_stock_total"/>
<field name="return_reuse_num_re"/>
<field name="return_reuse_num_co"/>
<field name="return_processing_num"/>
<field name="return_total"/>
<field name="total"/>
<field name="remark"/>
</tree>
</field>
</record>
<record id="sf_functional_tool_real_time_distribution_view_act" model="ir.actions.act_window">
<field name="name">功能刀具实时分布</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.cutting.tool.entity</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="sf_functional_tool_real_time_distribution_view_tree"/>
</record>
</data>
</odoo>