diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index d4d1a7ba..333d1723 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -139,35 +139,23 @@ class MachineTableToolChangingApply(models.Model):
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
- # def sync_tool_entity_from_tool_changing_apply_table(self):
- # """
- # ‘功能刀具预警’数据同步到‘机床换刀申请’
- # """
- # # 获取源表中的所有记录
- # source_records = self.env['sf.functional.cutting.tool.entity'].search([])
- #
- # # 循环遍历每个记录
- # for source_record in source_records:
- # # 检查目标表中是否存在相同的记录
- # destination_record = self.search([('CNC_machine_table', '=', source_record.machine_tool_code)])
- # if destination_record:
- # # todo 如果目标表中已经存在相同的记录,则更新该记录
- # destination_record.name = source_record.name
- # else:
- # # todo 如果目标表中不存在相同的记录,则创建一个新记录
- # destination_record = self.create({
- # # 'name': source_record.name,
- # })
+ status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0')
- def amendant_record(self, vals):
+ def new_assembly_task(self,vals):
"""
- 确认换刀申请(按键)
- 将弹窗数据更新到记录
+ 新建组装任务
:param vals:
:return:
"""
- self.env['sf.machine.table.tool.changing.apply'].search(
- [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]).write(vals)
+ # todo 设置直径的值
+ # tool_changing_apply = self.env['sf.machine.table.tool.changing.apply'].search(
+ # [('CNC_machine_table', '=', vals.get('CNC_machine_table'))])
+ # for i in tool_changing_apply:
+ # print(i)
+ # vals['functional_tool_diameter'] = tool_changing_apply.diameter
+
+ self.env['sf.functional.tool.assembly'].create(vals)
+
def revocation_1(self):
"""
@@ -175,26 +163,33 @@ class MachineTableToolChangingApply(models.Model):
:return:
"""
# 撤回数据更新
- self.env['sf.machine.table.tool.changing.apply'].search(
- [('CNC_machine_table', '=', self.CNC_machine_table)]).write({
- 'replacement_tool_code': False,
- 'replacement_tool_name': False,
- 'replacement_tool_type': False,
- 'replacement_tool_coarse_middle_thin': False,
- 'new_former': False,
- 'applicant': False,
- 'used_tool_time': False,
- 'reason_for_applying': False,
- 'remark': False
+ self.env['sf.machine.table.tool.changing.apply'].search([('CNC_machine_table', '=', self.CNC_machine_table)]).write({
+ 'replacement_tool_code': None,
+ 'replacement_tool_name': None,
+ 'replacement_tool_type': None,
+ 'replacement_tool_coarse_middle_thin': None,
+ 'new_former': None,
+ 'applicant': None,
+ 'used_tool_time': None,
+ 'reason_for_applying': None,
+ 'remark': None,
+ 'status': '0'
})
- # todo 撤回功能刀具组装创建新任务
+ # 撤回功能刀具组装创建新任务
+ self.env['sf.functional.tool.assembly'].search(
+ [('functional_tool_code', '=', self.functional_tool_code)]).unlink()
- def revocation_1(self):
+
+ def revocation_2(self):
"""
转移撤回按键
:return:
"""
+ self.env['sf.machine.table.tool.changing.apply'].search(
+ [('CNC_machine_table', '=', self.CNC_machine_table)]).write({
+ 'status': '0'
+ })
class CAMWorkOrderProgramKnifePlan(models.Model):
@@ -222,3 +217,62 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
applicant = fields.Char(string='申请人')
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
+
+ def revocation(self):
+ """
+ 撤回装刀申请
+ :return:
+ """
+ self.env['sf.functional.tool.assembly'].search(
+ [('functional_tool_code', '=', self.functional_tool_code)]).unlink()
+
+ # 将计划执行状态改为待执行
+ self.env['sf.cam.work.order.program.knife.plan'].search(
+ [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '0'})
+
+
+
+
+
+class FunctionalToolAssembly(models.Model):
+ _name = 'sf.functional.tool.assembly'
+ _description = '功能刀具组装'
+
+ functional_tool_code = fields.Char(string='功能刀具编码')
+ functional_tool_name = fields.Char(string='功能刀具名称')
+ functional_tool_type = fields.Char(string='功能刀具类型')
+ functional_tool_diameter = fields.Char(string='功能刀具直径')
+ functional_tool_length = fields.Char(string='功能刀具伸出长')
+ functional_tool_cutting_type = fields.Char(string='功能刀具切削类型')
+
+ tool_name = fields.Char(string='刀具名称')
+ tool_brand = fields.Char(string='品牌')
+ tool_type = fields.Char(string='型号')
+ knife_handle_name = fields.Char(string='刀柄名称')
+ knife_handle_brand = fields.Char(string='品牌')
+ knife_handle_type = fields.Char(string='型号')
+
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精')
+ tool_loading_length = fields.Char(string='装刀长')
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧')
+ reference_length = fields.Char(string='参考伸出长')
+ cut_time = fields.Char(string='已切削时间')
+ cut_length = fields.Char(string='已切削长度')
+ cut_number = fields.Char(string='已切削次数')
+
+ loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源')
+ applicant = fields.Char(string='申请人')
+ reason_for_applying = fields.Char(string='申请原因')
+ apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now())
+
+ assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')],string='组装状态', default='0')
+ use_tool_time = fields.Datetime(string='用刀时间')
+ production_line_name = fields.Char(string='产线名称')
+ machine_tool_name = fields.Char(string='机床名称')
+ machine_tool_code = fields.Char(string='机台号')
+ cutter_spacing_code = fields.Char(string='刀位号')
+ tool_loading_person = fields.Char(string='装刀人')
+ tool_loading_time = fields.Datetime(string='装刀时间')
+ receive_person = fields.Char(string='领用人')
+ receive_time = fields.Datetime(string='领用出库时间')
+ remark = fields.Char(string='备注说明')
diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv
index e97c88f8..e481edaa 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -8,6 +8,8 @@ access_sf_tool_change_requirement_information,sf.tool.change.requirement.informa
access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,base.group_user,1,1,1,1
access_sf_apply_for_tooling,sf.apply.for.tooling,model_sf_apply_for_tooling,base.group_user,1,1,1,1
+access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1
+
diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml
index b0fc131c..fbb58dda 100644
--- a/sf_tool_management/views/menu_view.xml
+++ b/sf_tool_management/views/menu_view.xml
@@ -72,5 +72,14 @@
parent="menu_sf_function_tool_plan"
/>
+
+
+
\ No newline at end of file
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 22c780cd..54372dfc 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -164,6 +164,7 @@
+
-
+
-
-
-
+
+
+
+
@@ -261,9 +266,15 @@
'default_coarse_middle_thin': coarse_middle_thin,
'default_whether_standard_tool': whether_standard_tool,
'default_need_knife_time': need_knife_time,
+ 'default_applicant': applicant,
'default_required_cutting_time': required_cutting_time,
'default_reason_for_applying': reason_for_applying}"
+ class="btn-primary"
+ attrs="{'invisible': [('plan_execute_status', '!=', '0')]}"
/>
+
+
+
@@ -276,7 +287,63 @@
+
+
+ CAM工单程序用刀计划
+ sf.functional.tool.assembly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CAM工单程序用刀计划
+ ir.actions.act_window
+ sf.functional.tool.assembly
+ tree,form
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 60fcfd86..fe986fff 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -40,12 +40,26 @@ class ToolChangeRequirementInformation(models.TransientModel):
'applicant': self.applicant,
'used_tool_time': self.used_tool_time,
'reason_for_applying': self.reason_for_applying,
- 'remark': self.new_former
+ 'remark': self.new_former,
+ 'status': '1'
}
# 将数据更新到换刀申请
- self.env['sf.machine.table.tool.changing.apply'].amendant_record(desc)
+ self.env['sf.machine.table.tool.changing.apply'].search(
+ [('CNC_machine_table', '=', desc.get('CNC_machine_table'))]).write(desc)
- # todo 功能刀具组装创建新任务
+ # 功能刀具组装创建新任务
+ self.env['sf.machine.table.tool.changing.apply'].new_assembly_task({
+ 'functional_tool_code': self.replacement_tool_code,
+ 'functional_tool_name': self.replacement_tool_name,
+ 'functional_tool_type': self.replacement_tool_type,
+ '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
+ })
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
@@ -81,6 +95,8 @@ class ToolTransferRequestInformation(models.TransientModel):
刀具转移申请信息确定按钮
:return:
"""
+ self.env['sf.machine.table.tool.changing.apply'].search(
+ [('CNC_machine_table', '=', self.CNC_machine_table)]).write({'status': '2'})
class ApplyForTooling(models.TransientModel):
@@ -107,11 +123,36 @@ class ApplyForTooling(models.TransientModel):
required_cutting_time = fields.Char(string='需要切割时间', readonly=True)
reason_for_applying = fields.Char(string='申请原因', readonly=True)
+ applicant = fields.Char(string='申请人', invisible='1')
+
def apply_for_tooling(self):
"""
-
+ 申请装刀
:return:
"""
+ 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,
+ 'functional_tool_length': self.tool_loading_length,
+ 'loading_task_source': '0',
+ 'coarse_middle_thin': None,
+ 'tool_loading_length': None,
+ 'applicant': self.applicant,
+ 'reason_for_applying': self.reason_for_applying,
+ 'use_tool_time': self.need_knife_time,
+ 'machine_tool_name': self.machine_table_name,
+ 'machine_tool_code': self.cam_procedure_code,
+ 'cutter_spacing_code': self.cam_cutter_spacing_code
+ })
+
+ # 将计划执行状态改为执行中
+ self.env['sf.cam.work.order.program.knife.plan'].search(
+ [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1'})
+
+ # 关闭弹出窗口
+ return {'type': 'ir.actions.act_window_close'}