增加了机台换刀申请和CAM程序用刀计划的搜索视图,增加了机台换刀申请的自动换刀功能,增加了CAM程序用刀计划的自动换刀申请功能(待完善)

This commit is contained in:
yuxianghui
2023-06-27 10:20:31 +08:00
parent 1348712c83
commit e880b020c6
3 changed files with 161 additions and 12 deletions

View File

@@ -126,7 +126,7 @@ class MachineTableToolChangingApply(models.Model):
max_lifetime_value = fields.Char(string='最大寿命值') max_lifetime_value = fields.Char(string='最大寿命值')
alarm_value = fields.Char(string='报警值') alarm_value = fields.Char(string='报警值')
used_value = fields.Char(string='已使用值') used_value = fields.Char(string='已使用值')
functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态') functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', default='正常')
replacement_tool_code = fields.Char(string='待换刀具编码') replacement_tool_code = fields.Char(string='待换刀具编码')
replacement_tool_name = fields.Char(string='待换刀具名称') replacement_tool_name = fields.Char(string='待换刀具名称')
@@ -141,18 +141,58 @@ class MachineTableToolChangingApply(models.Model):
status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0') status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0')
@api.onchange('functional_tool_status')
def automation_apply_for_tool_change(self):
"""
自动申请换刀
:return:
"""
# 更新数据到机台换刀申请界面
# todo 换刀申请条件需补充完善
if(self.functional_tool_status == '异常'):
self.env['sf.machine.table.tool.changing.apply'].search([
('CNC_machine_table', '=', self.CNC_machine_table)]).write({
'replacement_tool_code': self.functional_tool_code,
'replacement_tool_name': self.functional_tool_name,
'replacement_tool_type': self.functional_tool_type,
'replacement_tool_coarse_middle_thin': self.coarse_middle_thin,
'new_former': '0',
'applicant': '自动申请',
'used_tool_time': fields.Datetime.now(),
'reason_for_applying': '功能刀具状态异常',
'remark': None,
'status': '1'
})
# 新建组装任务
self.env['sf.functional.tool.assembly'].create({
'functional_tool_code': self.functional_tool_code,
'functional_tool_name': self.functional_tool_name,
'functional_tool_type': self.functional_tool_type,
'functional_tool_diameter': self.diameter,
'loading_task_source': '1',
'applicant': self.applicant,
'reason_for_applying': self.reason_for_applying,
'use_tool_time': self.used_tool_time,
'machine_tool_name': self.CNC_machine_table,
'machine_tool_code': self.machine_tool_code,
'cutter_spacing_code': self.cutter_spacing_code
})
def new_assembly_task(self,vals): def new_assembly_task(self,vals):
""" """
新建组装任务 新建组装任务
:param vals: :param vals:
:return: :return:
""" """
# todo 设置直径的值 # todo 增加设置直径的值
# tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search( # tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search(
# [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]) # [('CNC_machine_table', '=', vals.get('CNC_machine_table'))])
# for i in tool_changing_apply: # for i in tool_changing_apply:
# print(i) # print(i)
# vals['functional_tool_diameter'] = tool_changing_apply.diameter # vals['functional_tool_diameter'] = self.diameter
self.env['sf.functional.tool.assembly'].create(vals) self.env['sf.functional.tool.assembly'].create(vals)
@@ -218,6 +258,12 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
reason_for_applying = fields.Char(string='申请原因') reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明') remark = fields.Char(string='备注说明')
def automation_apply_for_tooling(self):
"""
todo 自动申请装刀
:return:
"""
def revocation(self): def revocation(self):
""" """
撤回装刀申请 撤回装刀申请

View File

@@ -176,10 +176,10 @@
'default_replacement_tool_name': functional_tool_name, 'default_replacement_tool_name': functional_tool_name,
'default_replacement_tool_type': functional_tool_type, 'default_replacement_tool_type': functional_tool_type,
'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}" 'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}"
attrs="{'invisible': ['|',('functional_tool_status', '=', '正常'), ('status', '!=', '0')]}" attrs="{'invisible': [('status', '!=', '0')]}"
class="btn-primary" class="btn-primary"
/> />
<button string="换刀申请" name="" attrs="{'invisible': [ ('functional_tool_status', '=', '异常'), ('status', '=', '0')]}" class="btn-primary"/> <button string="换刀申请" name="" attrs="{'invisible': [('status', '=', '0')]}" class="btn-primary"/>
<button string="转移" <button string="转移"
name="%(sf_tool_management.sf_tool_transfer_request_information_act)d" name="%(sf_tool_management.sf_tool_transfer_request_information_act)d"
@@ -211,13 +211,45 @@
</field> </field>
</record> </record>
<record id="sf_machine_table_tool_changing_apply_search" model="ir.ui.view" >
<field name="model">sf.machine.table.tool.changing.apply</field>
<field name="arch" type="xml">
<search>
<field name="CNC_machine_table"/>
<field name="machine_tool_code" invisible="1"/>
<field name="machine_table_type"/>
<field name="cutter_spacing_code"/>
<field name="functional_tool_code"/>
<field name="functional_tool_name"/>
<field name="functional_tool_type"/>
<field name="diameter"/>
<field name="coarse_middle_thin"/>
<field name="hilt_name"/>
<field name="hilt_code"/>
<field name="max_lifetime_value"/>
<field name="alarm_value"/>
<field name="used_value"/>
<field name="functional_tool_status"/>
<field name="replacement_tool_code"/>
<field name="replacement_tool_name"/>
<field name="replacement_tool_type"/>
<field name="replacement_tool_coarse_middle_thin"/>
<field name="new_former"/>
<field name="applicant"/>
<field name="used_tool_time"/>
<field name="reason_for_applying"/>
<field name="remark"/>
</search>
</field>
</record>
<!-- <record id="sf_machine_table_tool_changing_apply_search" model="ir.ui.view">--> <!-- <record id="sf_machine_table_tool_changing_apply_search" model="ir.ui.view">-->
<record id="sf_machine_table_tool_changing_apply_view_act" model="ir.actions.act_window"> <record id="sf_machine_table_tool_changing_apply_view_act" model="ir.actions.act_window">
<field name="name">机床换刀申请</field> <field name="name">机床换刀申请</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.machine.table.tool.changing.apply</field> <field name="res_model">sf.machine.table.tool.changing.apply</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form,search</field>
</record> </record>
@@ -279,17 +311,46 @@
</field> </field>
</record> </record>
<record id="sf_cam_work_order_program_knife_plan_search" model="ir.ui.view" >
<field name="model">sf.cam.work.order.program.knife.plan</field>
<field name="arch" type="xml">
<search>
<field name="ticket_task_code"/>
<field name="cam_procedure_code"/>
<field name="cam_cutter_spacing_code"/>
<field name="functional_tool_code"/>
<field name="functional_tool_name"/>
<field name="functional_tool_type"/>
<field name="machine_table_name"/>
<field name="machine_tool_cutter_spacing_code"/>
<field name="diameter"/>
<field name="tool_loading_length"/>
<field name="clearance_length"/>
<field name="tool_included_angle"/>
<field name="L_D"/>
<field name="coarse_middle_thin"/>
<field name="required_cutting_time"/>
<field name="whether_standard_tool"/>
<field name="need_knife_time"/>
<field name="plan_execute_status"/>
<field name="applicant"/>
<field name="reason_for_applying"/>
<field name="remark"/>
</search>
</field>
</record>
<record id="sf_cam_work_order_program_knife_plan_view_act" model="ir.actions.act_window"> <record id="sf_cam_work_order_program_knife_plan_view_act" model="ir.actions.act_window">
<field name="name">CAM工单程序用刀计划</field> <field name="name">CAM工单程序用刀计划</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.cam.work.order.program.knife.plan</field> <field name="res_model">sf.cam.work.order.program.knife.plan</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form,search</field>
</record> </record>
<!--================================================CAM工单程序用刀计划================================================--> <!--================================================功能刀具组装================================================-->
<record id="sf_functional_tool_assembly_tree" model="ir.ui.view"> <record id="sf_functional_tool_assembly_tree" model="ir.ui.view">
<field name="name">CAM工单程序用刀计划</field> <field name="name">功能刀具组装</field>
<field name="model">sf.functional.tool.assembly</field> <field name="model">sf.functional.tool.assembly</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree>
@@ -338,11 +399,53 @@
</field> </field>
</record> </record>
<record id="sf_functional_tool_assembly_search" model="ir.ui.view" >
<field name="model">sf.functional.tool.assembly</field>
<field name="arch" type="xml">
<search>
<field name="functional_tool_code"/>
<field name="functional_tool_name"/>
<field name="functional_tool_type"/>
<field name="functional_tool_diameter"/>
<field name="functional_tool_length"/>
<field name="functional_tool_cutting_type"/>
<field name="tool_name"/>
<field name="tool_brand"/>
<field name="tool_type"/>
<field name="knife_handle_name"/>
<field name="knife_handle_brand"/>
<field name="knife_handle_type"/>
<field name="coarse_middle_thin"/>
<field name="tool_loading_length"/>
<field name="new_former"/>
<field name="reference_length"/>
<field name="cut_time"/>
<field name="cut_length"/>
<field name="cut_number"/>
<field name="loading_task_source"/>
<field name="applicant"/>
<field name="reason_for_applying"/>
<field name="apply_time"/>
<field name="assemble_status"/>
<field name="use_tool_time"/>
<field name="production_line_name"/>
<field name="machine_tool_name"/>
<field name="machine_tool_code"/>
<field name="cutter_spacing_code"/>
<field name="tool_loading_person"/>
<field name="tool_loading_time"/>
<field name="receive_person"/>
<field name="receive_time"/>
<field name="remark"/>
</search>
</field>
</record>
<record id="sf_functional_tool_assembly_view_act" model="ir.actions.act_window"> <record id="sf_functional_tool_assembly_view_act" model="ir.actions.act_window">
<field name="name">CAM工单程序用刀计划</field> <field name="name">功能刀具组装</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.functional.tool.assembly</field> <field name="res_model">sf.functional.tool.assembly</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form,search</field>
</record> </record>

View File

@@ -43,7 +43,7 @@ class ToolChangeRequirementInformation(models.TransientModel):
'remark': self.new_former, 'remark': self.new_former,
'status': '1' 'status': '1'
} }
# 将数据更新到换刀申请 # 将数据更新到机台换刀申请界面
self.env['sf.machine.table.tool.changing.apply'].search( self.env['sf.machine.table.tool.changing.apply'].search(
[('CNC_machine_table', '=', desc.get('CNC_machine_table'))]).write(desc) [('CNC_machine_table', '=', desc.get('CNC_machine_table'))]).write(desc)