From 6caae0325a5cc96b208caae9ed1a0832ee70b0cf Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Tue, 20 Jun 2023 16:51:06 +0800
Subject: [PATCH 1/7] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E8=AE=A1=E5=88=92=EF=BC=88=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7?=
=?UTF-8?q?=E5=92=8CCAM=E5=B7=A5=E5=8D=95=E7=A8=8B=E5=BA=8F=E7=94=A8?=
=?UTF-8?q?=E5=88=80=E8=AE=A1=E5=88=92=EF=BC=89=E8=A7=86=E5=9B=BE=E5=B7=B2?=
=?UTF-8?q?=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 101 +++++++++++++++++-
.../security/ir.model.access.csv | 2 +
sf_tool_management/views/menu_view.xml | 23 ++++
sf_tool_management/views/tool_base_views.xml | 85 ++++++++++++++-
4 files changed, 208 insertions(+), 3 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index ae13cb56..8932b3a3 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -26,7 +26,7 @@ class FunctionalCuttingToolEntity(models.Model):
remark = fields.Char('备注')
# 功能刀具出入库记录 特有字段
- thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '细')], string='粗/中/细')
+ thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精')
max_life_span = fields.Char(string='最大寿命值')
# alarm_value = fields.Char(string='报警值')
# used_value = fields.Char(string='已使用值')
@@ -56,7 +56,8 @@ class FunctionalCuttingToolEntity(models.Model):
return_processing_num = fields.Text(string='归还需磨削数量')
return_total = fields.Text(string='合计')
total = fields.Text(string='总计')
- # remark = fields.Text(string='备注/说明')
+
+ # remark = fields.Char(string='备注/说明')
# @api.onchange('functional_cutting_tool_id')
# def get_functional_cutting_tool_info(self):
@@ -97,3 +98,99 @@ class FunctionalCuttingToolEntity(models.Model):
else:
new_code = '001'
return new_code
+
+
+class MachineTableToolChangingApply(models.Model):
+ _name = 'sf.machine.table.tool.changing.apply'
+ _description = '机床换刀申请'
+
+ CNC_machine_table = fields.Char(string='CNC机床')
+ # todo 机床类型和刀位号 为 Many2one
+ machine_table_type = fields.Char(string='机床类型')
+ cutter_spacing_code = fields.Char(string='刀位号')
+ functional_tool_code = fields.Char(string='功能刀具编码')
+ functional_tool_name = fields.Char(string='功能刀具名称')
+ # todo 功能刀具类型为 Many2one
+ functional_tool_type = fields.Char(string='功能刀具类型')
+ diameter = fields.Char(string='直径')
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精')
+ hilt_name = fields.Char(string='刀柄名称')
+ hilt_code = fields.Char(string='刀柄编号')
+ max_lifetime_value = fields.Char(string='最大寿命值')
+ alarm_value = fields.Char(string='报警值')
+ used_value = fields.Char(string='已使用值')
+ functional_tool_status = fields.Selection([("0", "正常"), ('1', '异常')], string='功能刀具状态')
+
+ replacement_tool_code = fields.Char(string='待换刀具编码')
+ replacement_tool_name = fields.Char(string='待换刀具名称')
+ replacement_tool_type = fields.Char(string='待换刀具类型')
+ replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
+ string='粗/中/精')
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧')
+ applicant = fields.Char(string='申请人')
+ used_tool_time = fields.Datetime(string='用刀时间')
+ 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:
+ # 如果目标表中不存在相同的记录,则创建一个新记录
+ destination_record = self.create({
+ # todo
+ # 'name': source_record.name,
+ })
+
+ # todo
+ def tool_changing_apply(self):
+ """
+ 换刀申请(按键)
+ """
+
+ # todo
+ def transfer(self):
+ """
+ 转移(按键)
+ """
+
+
+class CAMWorkOrderProgramKnifePlan(models.Model):
+ _name = 'sf.cam.work.order.program.knife.plan'
+ _description = 'CAM工单程序用刀计划'
+
+ CAM_cutter_spacing_code = fields.Char(string='CAM刀位号')
+ functional_tool_code = fields.Char(string='功能刀具编码')
+ functional_tool_name = fields.Char(string='功能刀具名称')
+ functional_tool_type = fields.Char(string='功能刀具类型')
+ machine_table_name = fields.Char(string='机台名称')
+ diameter = fields.Char(string='直径(程式)')
+ tool_loading_length = fields.Char(string='装刀长')
+ clearance_length = fields.Char(string='避空长')
+ tool_included_angle = fields.Char(string='刀尖角(R角)')
+ L_D = fields.Char(string='L/D')
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精')
+ required_cutting_time = fields.Char(string='需要切割时间')
+ whether_standard_tool = fields.Boolean(string='是否标准刀')
+ need_knife_time = fields.Datetime(string='需要用刀时间')
+ applicant = fields.Char(string='申请人')
+ reason_for_applying = fields.Char(string='申请原因')
+ remark = fields.Char(string='备注说明')
+
+ # todo
+ def tool_loading_apply(self):
+ """
+ 装刀申请(按键)
+ """
diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv
index 3156f716..7b514b89 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -1,5 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
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_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1
+access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,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 2abf6a11..b0fc131c 100644
--- a/sf_tool_management/views/menu_view.xml
+++ b/sf_tool_management/views/menu_view.xml
@@ -49,5 +49,28 @@
parent="menu_sf_tool_manage"
/>
+
+
+
+
+
+
\ 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 962759f4..baeb0882 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -36,7 +36,7 @@
-
+
功能刀具出入库记录
sf.functional.cutting.tool.entity
@@ -142,5 +142,88 @@
+
+
+
+ CAM工单程序用刀计划
+ sf.cam.work.order.program.knife.plan
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CAM工单程序用刀计划
+ ir.actions.act_window
+ sf.cam.work.order.program.knife.plan
+ tree,form
+
+
+
+
+
+ 机床换刀申请
+ sf.machine.table.tool.changing.apply
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 机床换刀申请
+ ir.actions.act_window
+ sf.machine.table.tool.changing.apply
+ tree,form
+
+
+
+
From f135f0a5e7e14dbcb52b87c517cf9a54fe9ba8ca Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Wed, 21 Jun 2023 17:21:58 +0800
Subject: [PATCH 2/7] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E5=BC=B9?=
=?UTF-8?q?=E7=AA=97=E6=8D=A2=E5=88=80=E9=9C=80=E6=B1=82=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E7=9A=84=E8=A7=86=E5=9B=BE=E5=92=8C=E9=BB=98=E8=AE=A4=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=90=8C=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/__init__.py | 1 +
sf_tool_management/__manifest__.py | 2 +-
sf_tool_management/models/base.py | 19 ++++---
.../security/ir.model.access.csv | 3 +
sf_tool_management/views/tool_base_views.xml | 23 +++++++-
sf_tool_management/wizard/__init__.py | 1 +
sf_tool_management/wizard/wizard.py | 35 ++++++++++++
sf_tool_management/wizard/wizard_view.xml | 57 +++++++++++++++++++
8 files changed, 129 insertions(+), 12 deletions(-)
create mode 100644 sf_tool_management/wizard/__init__.py
create mode 100644 sf_tool_management/wizard/wizard.py
create mode 100644 sf_tool_management/wizard/wizard_view.xml
diff --git a/sf_tool_management/__init__.py b/sf_tool_management/__init__.py
index c081ee06..c9ba0265 100644
--- a/sf_tool_management/__init__.py
+++ b/sf_tool_management/__init__.py
@@ -1,2 +1,3 @@
# -*-coding:utf-8-*-
from . import models
+from . import wizard
diff --git a/sf_tool_management/__manifest__.py b/sf_tool_management/__manifest__.py
index 8368f528..6fbf1152 100644
--- a/sf_tool_management/__manifest__.py
+++ b/sf_tool_management/__manifest__.py
@@ -14,9 +14,9 @@
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
+ 'wizard/wizard_view.xml',
'views/tool_base_views.xml',
'views/menu_view.xml',
-
],
'demo': [
],
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 8932b3a3..a33c7df1 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -104,9 +104,12 @@ class MachineTableToolChangingApply(models.Model):
_name = 'sf.machine.table.tool.changing.apply'
_description = '机床换刀申请'
+ apply_to_tool_change_ids = fields.One2many('sf.tool.change.requirement.information', 'tool_change_to_apply_id', string='换刀需求信息')
+
CNC_machine_table = fields.Char(string='CNC机床')
# todo 机床类型和刀位号 为 Many2one
machine_table_type = fields.Char(string='机床类型')
+ machine_tool_code = fields.Char(string='机台号', attrs="{'invisible': 1}")
cutter_spacing_code = fields.Char(string='刀位号')
functional_tool_code = fields.Char(string='功能刀具编码')
functional_tool_name = fields.Char(string='功能刀具名称')
@@ -119,7 +122,7 @@ class MachineTableToolChangingApply(models.Model):
max_lifetime_value = fields.Char(string='最大寿命值')
alarm_value = fields.Char(string='报警值')
used_value = fields.Char(string='已使用值')
- functional_tool_status = fields.Selection([("0", "正常"), ('1', '异常')], string='功能刀具状态')
+ functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态')
replacement_tool_code = fields.Char(string='待换刀具编码')
replacement_tool_name = fields.Char(string='待换刀具名称')
@@ -154,12 +157,6 @@ class MachineTableToolChangingApply(models.Model):
# 'name': source_record.name,
})
- # todo
- def tool_changing_apply(self):
- """
- 换刀申请(按键)
- """
-
# todo
def transfer(self):
"""
@@ -171,11 +168,14 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
_description = 'CAM工单程序用刀计划'
- CAM_cutter_spacing_code = fields.Char(string='CAM刀位号')
+ ticket_task_code = fields.Char(string='工单任务编号')
+ cam_procedure_code = fields.Char(string='CAM程序编号')
+ cam_cutter_spacing_code = fields.Char(string='CAM刀位号')
functional_tool_code = fields.Char(string='功能刀具编码')
functional_tool_name = fields.Char(string='功能刀具名称')
functional_tool_type = fields.Char(string='功能刀具类型')
- machine_table_name = fields.Char(string='机台名称')
+ machine_table_name = fields.Char(string='机床名称')
+ machine_tool_cutter_spacing_code = fields.Char(string='机床刀位号')
diameter = fields.Char(string='直径(程式)')
tool_loading_length = fields.Char(string='装刀长')
clearance_length = fields.Char(string='避空长')
@@ -185,6 +185,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
required_cutting_time = fields.Char(string='需要切割时间')
whether_standard_tool = fields.Boolean(string='是否标准刀')
need_knife_time = fields.Datetime(string='需要用刀时间')
+ plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')], string='计划执行状态')
applicant = fields.Char(string='申请人')
reason_for_applying = fields.Char(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 7b514b89..ebc4d2db 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -4,6 +4,9 @@ access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan
access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1
+access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,base.group_user,1,1,1,1
+
+
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index baeb0882..6637d0e9 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -149,11 +149,14 @@
sf.cam.work.order.program.knife.plan
-
+
+
+
+
@@ -163,6 +166,7 @@
+
@@ -186,6 +190,7 @@
+
@@ -200,7 +205,17 @@
-
+
@@ -216,6 +231,10 @@
+
+
+
+
机床换刀申请
ir.actions.act_window
diff --git a/sf_tool_management/wizard/__init__.py b/sf_tool_management/wizard/__init__.py
new file mode 100644
index 00000000..20a7f5c4
--- /dev/null
+++ b/sf_tool_management/wizard/__init__.py
@@ -0,0 +1 @@
+from . import wizard
\ No newline at end of file
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
new file mode 100644
index 00000000..3f4a0734
--- /dev/null
+++ b/sf_tool_management/wizard/wizard.py
@@ -0,0 +1,35 @@
+from odoo import fields, models, api
+
+
+class ToolChangeRequirementInformation(models.TransientModel):
+ _name = 'sf.tool.change.requirement.information'
+ _description = '换刀需求信息'
+
+ tool_change_to_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', string='机床换刀申请')
+
+ CNC_machine_table = fields.Char(string='CNC机床', readonly=True)
+ machine_tool_code = fields.Char(string='机台号', readonly=True)
+ cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
+
+ replacement_tool_code = fields.Char(string='待换刀具编码')
+ replacement_tool_name = fields.Char(string='待换刀具名称')
+ replacement_tool_type = fields.Char(string='待换刀具类型')
+ replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
+ string='粗/中/精')
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧')
+ applicant = fields.Char(string='申请人')
+ used_tool_time = fields.Datetime(string='用刀时间')
+ reason_for_applying = fields.Char(string='申请原因')
+ remark = fields.Char(string='备注说明')
+
+ # todo 未完成
+ def tool_changing_apply(self):
+ """
+ 确认换刀申请(按键)
+ """
+ # 将数据更新到换刀申请
+ self.tool_change_to_apply_id.write({'replacement_tool_name': self.replacement_tool_name})
+ self.env.cr.commit()
+
+ # 关闭弹出窗口
+ return {'type': 'ir.actions.act_window_close'}
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
new file mode 100644
index 00000000..8cdb7998
--- /dev/null
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -0,0 +1,57 @@
+
+
+
+ 换刀需求信息
+ sf.tool.change.requirement.information
+
+
+
+
+
+
+ 换刀需求信息
+ ir.actions.act_window
+ sf.tool.change.requirement.information
+ form
+
+ new
+
+
+
\ No newline at end of file
From c37166397e1fa5a7dbd354ae80cac87cf0fc9c10 Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Sun, 25 Jun 2023 17:36:33 +0800
Subject: [PATCH 3/7] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E6=9C=BA?=
=?UTF-8?q?=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E7=9A=84=E6=8D=A2?=
=?UTF-8?q?=E5=88=80=E7=94=B3=E8=AF=B7=E6=8C=89=E9=94=AE=E5=BC=B9=E7=AA=97?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E5=9B=9E=E6=9C=BA=E5=8F=B0?=
=?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E7=95=8C=E9=9D=A2=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E8=BD=AC=E7=A7=BB=E6=8C=89=E9=94=AE=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E3=80=81CAM=E5=B7=A5=E5=8D=95=E7=A8=8B=E5=BA=8F=E7=94=A8?=
=?UTF-8?q?=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84=E7=94=B3=E8=AF=B7=E8=A3=85?=
=?UTF-8?q?=E5=88=80=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 89 ++++++----
.../security/ir.model.access.csv | 2 +
sf_tool_management/views/tool_base_views.xml | 152 +++++++++++-------
sf_tool_management/wizard/wizard.py | 96 ++++++++++-
sf_tool_management/wizard/wizard_view.xml | 123 ++++++++++++++
5 files changed, 369 insertions(+), 93 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index a33c7df1..d4d1a7ba 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -104,7 +104,11 @@ class MachineTableToolChangingApply(models.Model):
_name = 'sf.machine.table.tool.changing.apply'
_description = '机床换刀申请'
- apply_to_tool_change_ids = fields.One2many('sf.tool.change.requirement.information', 'tool_change_to_apply_id', string='换刀需求信息')
+ apply_to_tool_change_ids = fields.One2many(
+ 'sf.tool.change.requirement.information',
+ 'tool_change_to_apply_id',
+ string='换刀需求信息',
+ attrs="{'invisible': 1}")
CNC_machine_table = fields.Char(string='CNC机床')
# todo 机床类型和刀位号 为 Many2one
@@ -135,32 +139,61 @@ 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([])
+ # 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,
+ # })
- # 循环遍历每个记录
- 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:
- # 如果目标表中不存在相同的记录,则创建一个新记录
- destination_record = self.create({
- # todo
- # 'name': source_record.name,
- })
-
- # todo
- def transfer(self):
+ def amendant_record(self, vals):
"""
- 转移(按键)
+ 确认换刀申请(按键)
+ 将弹窗数据更新到记录
+ :param vals:
+ :return:
+ """
+ self.env['sf.machine.table.tool.changing.apply'].search(
+ [('CNC_machine_table', '=', vals.get('CNC_machine_table'))]).write(vals)
+
+ def revocation_1(self):
+ """
+ 换刀申请撤回按键
+ :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
+ })
+
+ # todo 撤回功能刀具组装创建新任务
+
+ def revocation_1(self):
+ """
+ 转移撤回按键
+ :return:
"""
@@ -189,9 +222,3 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
applicant = fields.Char(string='申请人')
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
-
- # todo
- def tool_loading_apply(self):
- """
- 装刀申请(按键)
- """
diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv
index ebc4d2db..e97c88f8 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -5,6 +5,8 @@ access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply
access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,base.group_user,1,1,1,1
+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
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 6637d0e9..22c780cd 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -143,6 +143,79 @@
+
+
+ 机床换刀申请
+ sf.machine.table.tool.changing.apply
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 机床换刀申请
+ ir.actions.act_window
+ sf.machine.table.tool.changing.apply
+ tree,form
+
+
+
CAM工单程序用刀计划
@@ -170,7 +243,27 @@
-
+
@@ -183,64 +276,7 @@
-
-
- 机床换刀申请
- sf.machine.table.tool.changing.apply
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 机床换刀申请
- ir.actions.act_window
- sf.machine.table.tool.changing.apply
- tree,form
-
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 3f4a0734..60fcfd86 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -22,14 +22,102 @@ class ToolChangeRequirementInformation(models.TransientModel):
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
- # todo 未完成
def tool_changing_apply(self):
"""
- 确认换刀申请(按键)
+ 确认换刀申请(按键)
+ :return:
"""
+ # 封装数据
+ desc = {
+ 'CNC_machine_table': self.CNC_machine_table,
+ 'machine_tool_code': self.machine_tool_code,
+ 'cutter_spacing_code': self.cutter_spacing_code,
+ 'replacement_tool_code': self.replacement_tool_code,
+ 'replacement_tool_name': self.replacement_tool_name,
+ 'replacement_tool_type': self.replacement_tool_type,
+ 'replacement_tool_coarse_middle_thin': self.replacement_tool_coarse_middle_thin,
+ 'new_former': self.new_former,
+ 'applicant': self.applicant,
+ 'used_tool_time': self.used_tool_time,
+ 'reason_for_applying': self.reason_for_applying,
+ 'remark': self.new_former
+ }
# 将数据更新到换刀申请
- self.tool_change_to_apply_id.write({'replacement_tool_name': self.replacement_tool_name})
- self.env.cr.commit()
+ self.env['sf.machine.table.tool.changing.apply'].amendant_record(desc)
+
+ # todo 功能刀具组装创建新任务
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
+
+
+class ToolTransferRequestInformation(models.TransientModel):
+ _name = 'sf.tool.transfer.request.information'
+ _description = '刀具转移申请信息'
+
+ CNC_machine_table = fields.Char(string='CNC机床', readonly=True)
+ machine_tool_code = fields.Char(string='机台号', readonly=True)
+ cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
+ functional_tool_code = fields.Char(string='功能刀具编码', readonly=True)
+ functional_tool_name = fields.Char(string='功能刀具名称', readonly=True)
+ # todo 功能刀具类型为 Many2one
+ functional_tool_type = fields.Char(string='功能刀具类型', readonly=True)
+ transfer_target = fields.Selection([('机台', '机台'),
+ ('线边刀库', '线边刀库'),
+ ('刀具房', '刀具房')], string='转移到:', default='线边刀库')
+
+ new_cnc_machine_table = fields.Char(string='机床名称')
+ new_machine_tool_code = fields.Char(string='机床号')
+ new_cutter_spacing_code = fields.Char(string='刀位号')
+
+ magazine_tool_warehouse_district = fields.Char(string='库区')
+ magazine_tool_warehouse_position = fields.Char(string='库位')
+
+ tool_room_warehouse_district = fields.Char(string='库区')
+ tool_room_warehouse_position = fields.Char(string='库位')
+
+ def tool_transfer_apply(self):
+ """
+ 刀具转移申请信息确定按钮
+ :return:
+ """
+
+
+class ApplyForTooling(models.TransientModel):
+ _name = 'sf.apply.for.tooling'
+ _description = '申请装刀'
+
+ ticket_task_code = fields.Char(string='工单任务编号', readonly=True)
+ cam_procedure_code = fields.Char(string='CAM程序编号', readonly=True)
+ machine_table_name = fields.Char(string='机床名称', readonly=True)
+ cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=True)
+ functional_tool_code = fields.Char(string='功能刀具编码', readonly=True)
+ functional_tool_name = fields.Char(string='功能刀具名称', readonly=True)
+ functional_tool_type = fields.Char(string='功能刀具类型', readonly=True)
+
+ diameter = fields.Char(string='直径(程式)', readonly=True)
+ tool_loading_length = fields.Char(string='装刀长', readonly=True)
+ clearance_length = fields.Char(string='避空长', readonly=True)
+ tool_included_angle = fields.Char(string='刀尖角(R角)', readonly=True)
+ L_D = fields.Char(string='L/D', readonly=True)
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
+
+ whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True)
+ need_knife_time = fields.Datetime(string='需要用刀时间', readonly=True)
+ required_cutting_time = fields.Char(string='需要切割时间', readonly=True)
+ reason_for_applying = fields.Char(string='申请原因', readonly=True)
+
+ def apply_for_tooling(self):
+ """
+
+ :return:
+ """
+
+
+
+
+
+
+
+
+
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index 8cdb7998..4706f86e 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -1,5 +1,6 @@
+
换刀需求信息
sf.tool.change.requirement.information
@@ -54,4 +55,126 @@
new
+
+
+
+ 刀具转移申请信息
+ sf.tool.transfer.request.information
+
+
+
+
+
+
+ 刀具转移申请信息
+ ir.actions.act_window
+ sf.tool.transfer.request.information
+ form
+
+ new
+
+
+
+
+
+ 申请装刀
+ sf.apply.for.tooling
+
+
+
+
+
+
+ 申请装刀
+ ir.actions.act_window
+ sf.apply.for.tooling
+ form
+
+ new
+
\ No newline at end of file
From 1348712c837243c17d6cff959e9483882360095b Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Mon, 26 Jun 2023 18:10:37 +0800
Subject: [PATCH 4/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BA=86=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E8=AE=A1=E5=88=92=E7=9A=84=E6=8C=89=E9=94=AE=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=8C=89=E9=94=AE=E7=9A=84?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 128 +++++++++++++-----
.../security/ir.model.access.csv | 2 +
sf_tool_management/views/menu_view.xml | 9 ++
sf_tool_management/views/tool_base_views.xml | 77 ++++++++++-
sf_tool_management/wizard/wizard.py | 49 ++++++-
5 files changed, 219 insertions(+), 46 deletions(-)
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'}
From e880b020c6560d4287ff86c0f8e505def6929207 Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Tue, 27 Jun 2023 10:20:31 +0800
Subject: [PATCH 5/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=9C=BA?=
=?UTF-8?q?=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=92=8CCAM?=
=?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84?=
=?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=A7=86=E5=9B=BE=EF=BC=8C=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E4=BA=86=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7?=
=?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E6=8D=A2=E5=88=80=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86CAM=E7=A8=8B=E5=BA=8F?=
=?UTF-8?q?=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=8A=9F=E8=83=BD=EF=BC=88?=
=?UTF-8?q?=E5=BE=85=E5=AE=8C=E5=96=84=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 52 +++++++-
sf_tool_management/views/tool_base_views.xml | 119 +++++++++++++++++--
sf_tool_management/wizard/wizard.py | 2 +-
3 files changed, 161 insertions(+), 12 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 333d1723..85cb2c9a 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -126,7 +126,7 @@ class MachineTableToolChangingApply(models.Model):
max_lifetime_value = fields.Char(string='最大寿命值')
alarm_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_name = fields.Char(string='待换刀具名称')
@@ -141,18 +141,58 @@ class MachineTableToolChangingApply(models.Model):
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):
"""
新建组装任务
:param vals:
:return:
"""
- # todo 设置直径的值
+ # 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
+ # vals['functional_tool_diameter'] = self.diameter
self.env['sf.functional.tool.assembly'].create(vals)
@@ -218,6 +258,12 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
+ def automation_apply_for_tooling(self):
+ """
+ todo 自动申请装刀
+ :return:
+ """
+
def revocation(self):
"""
撤回装刀申请
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 54372dfc..fbc25af9 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -176,10 +176,10 @@
'default_replacement_tool_name': functional_tool_name,
'default_replacement_tool_type': functional_tool_type,
'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}"
- attrs="{'invisible': ['|',('functional_tool_status', '=', '正常'), ('status', '!=', '0')]}"
+ attrs="{'invisible': [('status', '!=', '0')]}"
class="btn-primary"
/>
-
+