From d5749251229ff033fd277fe084a7d8a89c94b944 Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Tue, 1 Aug 2023 17:41:21 +0800
Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E5=88=80=E5=85=B7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86-=E6=9C=BA=E5=BA=8A=E6=8D=A2=E5=88=80=E7=94=B3?=
=?UTF-8?q?=E8=AF=B7=E3=80=81CAM=E5=B7=A5=E5=8D=95=E7=A8=8B=E5=BA=8F?=
=?UTF-8?q?=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E3=80=81=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=A2=9E=E5=8A=A0=E4=BA=86?=
=?UTF-8?q?=E6=9C=BA=E5=BA=8A=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E5=92=8C=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=B1=BB=E5=9E=8B?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?=
=?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86tree=E8=A7=86=E5=9B=BE?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8C=89=E9=94=AE=20=20=202=E3=80=81?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86CAM=E5=B7=A5=E5=8D=95=E7=A8=8B?=
=?UTF-8?q?=E5=BA=8F=E7=94=A8=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84=E6=8C=89?=
=?UTF-8?q?=E9=94=AE=E5=8A=9F=E8=83=BD=20=203=E3=80=81=E5=AF=B9=E4=B8=89?=
=?UTF-8?q?=E4=B8=AA=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=AD=97=E6=AE=B5=E7=9A=84?=
=?UTF-8?q?=E5=8F=AF=E8=AF=BB=E6=80=A7=E8=BF=9B=E8=A1=8C=E4=BA=86=E8=B0=83?=
=?UTF-8?q?=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 273 +++++++++---------
.../security/ir.model.access.csv | 1 -
sf_tool_management/views/tool_base_views.xml | 183 +++++++-----
sf_tool_management/wizard/wizard.py | 104 ++-----
sf_tool_management/wizard/wizard_view.xml | 97 +------
5 files changed, 288 insertions(+), 370 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 596e54bb..2c7ddf30 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -123,20 +123,20 @@ class FunctionalToolWarning(models.Model):
image = fields.Binary('图片', readonly=True)
# 功能刀具预警 特有字段
- install_tool_time = fields.Char("装刀时间", readonly=True)
- outbound_time = fields.Char('出库时间', readonly=True)
- on_board_time = fields.Char('上机时间', readonly=True)
- machine_tool_code = fields.Char('机台号', readonly=True)
- cutting_tool_code = fields.Char('刀位号', readonly=True)
- idle_time = fields.Char('闲置时长', readonly=True)
- alarm_value = fields.Char('报警值', readonly=True)
- used_value = fields.Char('已使用值', readonly=True)
- alarm_type = fields.Char('报警类型', readonly=True)
- alarm_time = fields.Char('报警时间', readonly=True)
- dispose_user = fields.Char('处理人', readonly=True)
- dispose_time = fields.Char('处理时间', readonly=True)
- dispose_func = fields.Char('处理方法/措施', readonly=True)
- remark = fields.Char('备注', readonly=True)
+ install_tool_time = fields.Char("装刀时间", readonly=False)
+ outbound_time = fields.Char('出库时间', readonly=False)
+ on_board_time = fields.Char('上机时间', readonly=False)
+ machine_tool_code = fields.Char('机台号', readonly=False)
+ cutting_tool_code = fields.Char('刀位号', readonly=False)
+ idle_time = fields.Char('闲置时长', readonly=False)
+ alarm_value = fields.Char('报警值', readonly=False)
+ used_value = fields.Char('已使用值', readonly=False)
+ alarm_type = fields.Char('报警类型', readonly=False)
+ alarm_time = fields.Char('报警时间', readonly=False)
+ dispose_user = fields.Char('处理人', readonly=False)
+ dispose_time = fields.Char('处理时间', readonly=False)
+ dispose_func = fields.Char('处理方法/措施', readonly=False)
+ remark = fields.Char('备注', readonly=False)
@api.onchange('functional_cutting_tool_id')
def onchange_functional_cutting_tool_id(self):
@@ -197,16 +197,16 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
image = fields.Binary('图片', readonly=True)
# 功能刀具实时分布
- tool_stock_num = fields.Char(string='刀具房库存数量', readonly=True)
- side_shelf_num = fields.Char(string='线边货架货架数量', readonly=True)
- on_tool_stock_num = fields.Char(string='机内刀库库存数量', readonly=True)
- tool_stock_total = fields.Char(string='合计', readonly=True)
- return_reuse_num_re = fields.Char(string='归还再用数量(精)', readonly=True)
- return_reuse_num_co = fields.Char(string='归还再用数量(粗)', readonly=True)
- return_processing_num = fields.Char(string='归还需磨削数量', readonly=True)
- return_total = fields.Char(string='合计', readonly=True)
- total = fields.Char(string='总计', readonly=True)
- remark = fields.Char(string='备注/说明', readonly=True)
+ tool_stock_num = fields.Char(string='刀具房库存数量', readonly=False)
+ side_shelf_num = fields.Char(string='线边货架货架数量', readonly=False)
+ on_tool_stock_num = fields.Char(string='机内刀库库存数量', readonly=False)
+ tool_stock_total = fields.Char(string='合计', readonly=False)
+ return_reuse_num_re = fields.Char(string='归还再用数量(精)', readonly=False)
+ return_reuse_num_co = fields.Char(string='归还再用数量(粗)', readonly=False)
+ return_processing_num = fields.Char(string='归还需磨削数量', readonly=False)
+ return_total = fields.Char(string='合计', readonly=False)
+ total = fields.Char(string='总计', readonly=False)
+ remark = fields.Char(string='备注/说明', readonly=False)
class InboundAndOutboundRecordsOfFunctionalTools(models.Model):
@@ -263,25 +263,25 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model):
image = fields.Binary('图片', readonly=True)
# 功能刀具出入库记录 特有字段
- thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
- max_life_span = fields.Char(string='最大寿命值', readonly=True)
- alarm_value = fields.Char(string='报警值', readonly=True)
- used_value = fields.Char(string='已使用值', readonly=True)
- current_state = fields.Char(string='当前状态', readonly=True)
- current_store_area = fields.Char(string='当前库区', readonly=True)
- current_store_place = fields.Char(string='当前库位', readonly=True)
- number = fields.Integer(string='数量', readonly=True)
- reason_application = fields.Char(string='申请原因', readonly=True)
- applicant = fields.Char(string='申请人', readonly=True)
- return_staff = fields.Char(string='归还人', readonly=True)
- return_time = fields.Date(string='归还入库时间', readonly=True)
- tool_state = fields.Char(string="刀具状态", readonly=True)
- tool_install_staff = fields.Char(string='装刀人', readonly=True)
- tool_install_time = fields.Datetime(string='装刀时间', readonly=True)
- receive_equipment = fields.Char(string='领用机台', readonly=True)
- receive_staff = fields.Char(string='领用人', readonly=True)
- receive_time = fields.Char(string='领用出库时间', readonly=True)
- remark = fields.Text(string='备注/说明', readonly=True)
+ thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
+ max_life_span = fields.Char(string='最大寿命值', readonly=False)
+ alarm_value = fields.Char(string='报警值', readonly=False)
+ used_value = fields.Char(string='已使用值', readonly=False)
+ current_state = fields.Char(string='当前状态', readonly=False)
+ current_store_area = fields.Char(string='当前库区', readonly=False)
+ current_store_place = fields.Char(string='当前库位', readonly=False)
+ number = fields.Integer(string='数量', readonly=False)
+ reason_application = fields.Char(string='申请原因', readonly=False)
+ applicant = fields.Char(string='申请人', readonly=False)
+ return_staff = fields.Char(string='归还人', readonly=False)
+ return_time = fields.Date(string='归还入库时间', readonly=False)
+ tool_state = fields.Char(string="刀具状态", readonly=False)
+ tool_install_staff = fields.Char(string='装刀人', readonly=False)
+ tool_install_time = fields.Datetime(string='装刀时间', readonly=False)
+ receive_equipment = fields.Char(string='领用机台', readonly=False)
+ receive_staff = fields.Char(string='领用人', readonly=False)
+ receive_time = fields.Char(string='领用出库时间', readonly=False)
+ remark = fields.Text(string='备注/说明', readonly=False)
class MachineTableToolChangingApply(models.Model):
@@ -294,37 +294,43 @@ class MachineTableToolChangingApply(models.Model):
# string='换刀需求信息',
# attrs="{'invisible': 1}")
- name = fields.Char(string='CNC机床', readonly="True")
- # todo 机床类型和刀位号 为 Many2one
- machine_table_type = fields.Char(string='机床类型', readonly="True")
+ name = fields.Many2one('sf.machine_tool', string='CNC机床', readonly=False)
+ machine_table_type_id = fields.Many2one('sf.machine_tool.category', string='机床类型', readonly=False)
machine_tool_code = fields.Char(string='机台号', attrs="{'invisible': 1}")
- 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")
- diameter = fields.Char(string='直径', readonly="True")
- coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly="True")
- hilt_name = fields.Char(string='刀柄名称', readonly="True")
- hilt_code = fields.Char(string='刀柄编号', readonly="True")
- max_lifetime_value = fields.Char(string='最大寿命值', readonly="True")
- alarm_value = fields.Char(string='报警值', readonly="True")
- used_value = fields.Char(string='已使用值', readonly="True")
- functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', default='正常', readonly="True")
+ cutter_spacing_code = fields.Char(string='刀位号', readonly=False)
+ functional_tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_functional_tool_name_id')
+ functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False)
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',string='功能刀具类型', readonly=True, compute='_compute_functional_tool_name_id')
+ diameter = fields.Char(string='直径', readonly=False)
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
+ hilt_name = fields.Char(string='刀柄名称', readonly=False)
+ hilt_code = fields.Char(string='刀柄编号', readonly=False)
+ max_lifetime_value = fields.Char(string='最大寿命值', readonly=False)
+ alarm_value = fields.Char(string='报警值', readonly=False)
+ used_value = fields.Char(string='已使用值', readonly=False)
+ functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', default='正常', readonly=False)
- replacement_tool_code = fields.Char(string='待换刀具编码', readonly="True")
- replacement_tool_name = fields.Char(string='待换刀具名称', readonly="True")
- replacement_tool_type = fields.Char(string='待换刀具类型', readonly="True")
+ replacement_tool_code = fields.Char(string='待换刀具编码', readonly=True)
+ replacement_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='待换刀具名称', readonly=True)
+ replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换刀具类型', readonly=True)
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
- string='粗/中/精', readonly="True")
- new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly="True")
- applicant = fields.Char(string='申请人', readonly="True")
- used_tool_time = fields.Datetime(string='用刀时间', readonly="True")
- reason_for_applying = fields.Char(string='申请原因', readonly="True")
- remark = fields.Char(string='备注说明', readonly="True")
+ string='粗/中/精', readonly=True)
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
+ applicant = fields.Char(string='申请人', readonly=True)
+ used_tool_time = fields.Datetime(string='用刀时间', readonly=True)
+ reason_for_applying = fields.Char(string='申请原因', readonly=True)
+ remark = fields.Char(string='备注说明', readonly=False)
status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0')
+ @api.depends('functional_tool_name_id')
+ def _compute_functional_tool_name_id(self):
+ for record in self:
+ if record:
+ record.functional_tool_code = record.functional_tool_name_id.code
+ record.functional_tool_type_id = record.functional_tool_name_id.mrs_cutting_tool_type_id.id
+
+
@api.onchange('functional_tool_status')
def automation_apply_for_tool_change(self):
"""
@@ -335,10 +341,10 @@ class MachineTableToolChangingApply(models.Model):
# todo 自动换刀申请条件需补充完善
if(self.functional_tool_status == '异常'):
self.env['sf.machine.table.tool.changing.apply'].search([
- ('name', '=', self.name)]).write({
+ ('name', '=', self.name.id)]).write({
'replacement_tool_code': self.functional_tool_code,
- 'replacement_tool_name': self.functional_tool_name,
- 'replacement_tool_type': self.functional_tool_type,
+ 'replacement_tool_name_id': self.functional_tool_name_id.id,
+ 'replacement_tool_type_id': self.functional_tool_type_id.id,
'replacement_tool_coarse_middle_thin': self.coarse_middle_thin,
'new_former': '0',
'applicant': '自动申请',
@@ -351,8 +357,8 @@ class MachineTableToolChangingApply(models.Model):
# 新建组装任务
self.env['sf.functional.tool.assembly'].create({
'functional_tool_code': self.functional_tool_code,
- 'name': self.functional_tool_name,
- 'functional_tool_type': self.functional_tool_type,
+ 'name': self.functional_tool_name_id,
+ 'functional_tool_type_id': self.functional_tool_type_id.id,
'functional_tool_diameter': self.diameter,
'loading_task_source': '1',
'applicant': '自动申请',
@@ -384,11 +390,16 @@ class MachineTableToolChangingApply(models.Model):
换刀申请撤回按键
:return:
"""
+ # 撤回功能刀具组装创建的任务
+ self.env['sf.functional.tool.assembly'].search(
+ [('functional_tool_code', '=', self.replacement_tool_code),
+ ('loading_task_source', '=', '机台换刀')]).unlink()
+
# 撤回数据更新
- self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name)]).write({
+ self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name.id)]).write({
'replacement_tool_code': None,
- 'replacement_tool_name': None,
- 'replacement_tool_type': None,
+ 'replacement_tool_name_id': None,
+ 'replacement_tool_type_id': None,
'replacement_tool_coarse_middle_thin': None,
'new_former': None,
'applicant': None,
@@ -398,10 +409,6 @@ class MachineTableToolChangingApply(models.Model):
'status': '0'
})
- # 撤回功能刀具组装创建新任务
- self.env['sf.functional.tool.assembly'].search(
- [('functional_tool_code', '=', self.functional_tool_code)]).unlink()
-
def revocation_2(self):
"""
@@ -409,7 +416,7 @@ class MachineTableToolChangingApply(models.Model):
:return:
"""
self.env['sf.machine.table.tool.changing.apply'].search(
- [('name', '=', self.name)]).write({
+ [('name', '=', self.name.id)]).write({
'status': '0'
})
@@ -418,38 +425,38 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
_description = 'CAM工单程序用刀计划'
- name = fields.Char(string='工单任务编号', readonly=True)
- cam_procedure_code = fields.Char(string='CAM程序编号', 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)
- machine_table_name = fields.Char(string='机床名称', readonly=True)
- machine_tool_cutter_spacing_code = 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)
- required_cutting_time = fields.Char(string='需要切割时间', readonly=True)
- whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True)
- need_knife_time = fields.Datetime(string='需要用刀时间', readonly=True)
+ name = fields.Char(string='工单任务编号', readonly=False)
+ cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False)
+ cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False)
+ functional_tool_code = fields.Char(string='功能刀具编码', readonly=False)
+ functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False)
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False)
+ machine_table_name_id = fields.Many2one('sf.machine_tool', string='机床名称', readonly=False)
+ machine_tool_cutter_spacing_code = fields.Char(string='机床刀位号', readonly=False)
+ diameter = fields.Char(string='直径(程式)', readonly=False)
+ tool_loading_length = fields.Char(string='装刀长', readonly=False)
+ clearance_length = fields.Char(string='避空长', readonly=False)
+ tool_included_angle = fields.Char(string='刀尖角(R角)', readonly=False)
+ L_D = fields.Char(string='L/D', readonly=False)
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
+ required_cutting_time = fields.Char(string='需要切割时间', readonly=False)
+ whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=False)
+ need_knife_time = fields.Datetime(string='需要用刀时间', readonly=False)
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
- string='计划执行状态', default='0', readonly=True)
- applicant = fields.Char(string='申请人', readonly=True)
- reason_for_applying = fields.Char(string='申请原因', readonly=True)
- remark = fields.Char(string='备注说明', readonly=True)
+ string='计划执行状态', default='0', readonly=False)
+ applicant = fields.Char(string='申请人', readonly=False)
+ reason_for_applying = fields.Char(string='申请原因', readonly=False)
+ remark = fields.Char(string='备注说明', readonly=False)
- def automation_apply_for_tooling(self):
+ def apply_for_tooling(self):
"""
- 自动申请装刀
+ 申请装刀
:return:
"""
self.env['sf.functional.tool.assembly'].create({
'functional_tool_code': self.functional_tool_code,
- 'name': self.functional_tool_name,
- 'functional_tool_type': self.functional_tool_type,
+ 'name': self.functional_tool_name_id.id,
+ 'functional_tool_type_id': self.functional_tool_type_id.id,
'functional_tool_diameter': self.diameter,
'functional_tool_length': self.tool_loading_length,
'loading_task_source': '0',
@@ -458,7 +465,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'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_name_id': self.machine_table_name_id.id,
'machine_tool_code': self.cam_procedure_code,
'cutter_spacing_code': self.cam_cutter_spacing_code
})
@@ -467,13 +474,15 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
self.env['sf.cam.work.order.program.knife.plan'].search(
[('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1'})
+
def revocation(self):
"""
撤回装刀申请
:return:
"""
self.env['sf.functional.tool.assembly'].search(
- [('functional_tool_code', '=', self.functional_tool_code)]).unlink()
+ [('functional_tool_code', '=', self.functional_tool_code),
+ ('loading_task_source', '=', 'CAM装刀')]).unlink()
# 将计划执行状态改为待执行
self.env['sf.cam.work.order.program.knife.plan'].search(
@@ -489,25 +498,25 @@ class FunctionalToolAssembly(models.Model):
_order = 'use_tool_time asc'
functional_tool_code = fields.Char(string='功能刀具编码', readonly=True)
- name = fields.Char(string='功能刀具名称', readonly=True)
- functional_tool_type = fields.Char(string='功能刀具类型', readonly=True)
+ name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
functional_tool_diameter = fields.Char(string='功能刀具直径', readonly=True)
functional_tool_length = fields.Char(string='功能刀具伸出长', readonly=True)
- functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=True)
+ functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
- tool_name = fields.Char(string='刀具名称', readonly=True)
- tool_brand = fields.Char(string='品牌', readonly=True)
- tool_type = fields.Char(string='型号', readonly=True)
- knife_handle_name = fields.Char(string='刀柄名称', readonly=True)
- knife_handle_brand = fields.Char(string='品牌', readonly=True)
- knife_handle_type = fields.Char(string='型号', readonly=True)
- coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
- tool_loading_length = fields.Char(string='装刀长', readonly=True)
- new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
- reference_length = fields.Char(string='参考伸出长', readonly=True)
- cut_time = fields.Char(string='已切削时间', readonly=True)
- cut_length = fields.Char(string='已切削长度', readonly=True)
- cut_number = fields.Char(string='已切削次数', readonly=True)
+ tool_name = fields.Char(string='刀具名称', readonly=False)
+ tool_brand = fields.Char(string='品牌', readonly=False)
+ tool_type = fields.Char(string='型号', readonly=False)
+ knife_handle_name = fields.Char(string='刀柄名称', readonly=False)
+ knife_handle_brand = fields.Char(string='品牌', readonly=False)
+ knife_handle_type = fields.Char(string='型号', readonly=False)
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
+ tool_loading_length = fields.Char(string='装刀长', readonly=False)
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=False)
+ reference_length = fields.Char(string='参考伸出长', readonly=False)
+ cut_time = fields.Char(string='已切削时间', readonly=False)
+ cut_length = fields.Char(string='已切削长度', readonly=False)
+ cut_number = fields.Char(string='已切削次数', readonly=False)
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True)
applicant = fields.Char(string='申请人', readonly=True)
@@ -515,8 +524,8 @@ class FunctionalToolAssembly(models.Model):
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')],string='组装状态', default='0', readonly=True)
use_tool_time = fields.Datetime(string='用刀时间', readonly=True)
- production_line_name = fields.Char(string='产线名称', readonly=True)
- machine_tool_name = fields.Char(string='机床名称', readonly=True)
+ production_line_name = fields.Char(string='产线名称', readonly=False)
+ machine_tool_name_id = fields.Many2one('sf.machine_tool', string='机床名称', readonly=True)
machine_tool_code = fields.Char(string='机台号', readonly=True)
cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
@@ -526,7 +535,7 @@ class FunctionalToolAssembly(models.Model):
receive_time = fields.Datetime(string='领用出库时间', readonly=True)
remark = fields.Char(string='备注说明', readonly=True)
- check_box_1 = fields.Boolean(string='复选框', default=False, readonly=True)
+ check_box_1 = fields.Boolean(string='复选框', default=False, readonly=False)
@api.onchange('assemble_status')
def check_box(self):
@@ -540,7 +549,7 @@ class FunctionalToolAssembly(models.Model):
:return:
"""
self.env['sf.functional.tool.assembly'].search([
- ('machine_tool_name', '=', self.machine_tool_name),
+ ('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code', '=', self.cutter_spacing_code)
]).write({
'tool_name': None,
@@ -575,8 +584,8 @@ class FunctionalToolAssembly(models.Model):
for val in vals:
self.env['sf.delivery.of.cargo.from.storage'].create({
'functional_tool_code': val.functional_tool_code,
- 'name': val.name,
- 'functional_tool_type': val.functional_tool_type,
+ 'name': val.name.id,
+ 'functional_tool_type_id': val.functional_tool_type_id.id,
'production_line_name': val.production_line_name,
'machine_tool_code': val.machine_tool_code,
'receive_person': val.receive_person,
@@ -585,8 +594,8 @@ class FunctionalToolAssembly(models.Model):
else:
self.env['sf.delivery.of.cargo.from.storage'].create({
'functional_tool_code': self.functional_tool_code,
- 'name': self.name,
- 'functional_tool_type': self.functional_tool_type,
+ 'name': self.name.id,
+ 'functional_tool_type_id': self.functional_tool_type_id.id,
'production_line_name': self.production_line_name,
'machine_tool_code': self.machine_tool_code,
'receive_person': self.receive_person,
diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv
index 65b027b6..1cb5d1a0 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -10,7 +10,6 @@ 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
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,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 fddba05e..becab19c 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -536,16 +536,44 @@
-
+
-
-
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
@@ -563,8 +591,8 @@
'default_machine_tool_code': machine_tool_code,
'default_cutter_spacing_code': cutter_spacing_code,
'default_replacement_tool_code': functional_tool_code,
- 'default_replacement_tool_name': functional_tool_name,
- 'default_replacement_tool_type': functional_tool_type,
+ 'default_replacement_tool_name_id': functional_tool_name_id,
+ 'default_replacement_tool_type_id': functional_tool_type_id,
'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}"
attrs="{'invisible': [('status', '!=', '0')]}"
class="btn-primary"
@@ -572,12 +600,12 @@
@@ -588,14 +616,14 @@
-
+
-
-
+
+
@@ -614,8 +642,8 @@
-
-
+
+
@@ -643,18 +671,16 @@
-
+
-
-
+
+
-
-
+
-
-
-
-
+
+
+
@@ -677,12 +703,15 @@
-
-
-
+
+
+
-
+
+
+
+
@@ -693,30 +722,7 @@
-
-
+
+
@@ -770,11 +776,14 @@
-
-
-
+
+
+
+
+
+
@@ -795,14 +804,40 @@
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -817,10 +852,10 @@
name="%(sf_tool_management.sf_functional_tool_assembly_order_act)d"
type="action"
context="{
- 'default_machine_tool_name': machine_tool_name,
+ 'default_machine_tool_name_id': machine_tool_name_id,
'default_cutter_spacing_code': cutter_spacing_code,
- 'default_functional_tool_name': name,
- 'default_functional_tool_type': functional_tool_type,
+ 'default_functional_tool_name_id': name,
+ 'default_functional_tool_type_id': functional_tool_type_id,
'default_functional_tool_length': functional_tool_length,
'default_effective_length': None,
'default_functional_tool_diameter': functional_tool_diameter,
@@ -844,7 +879,7 @@
-
+
@@ -874,7 +909,7 @@
-
+
@@ -914,14 +949,17 @@
-
+
-
+
+
+
+
@@ -932,8 +970,5 @@
sf.functional.tool.assembly
tree,form,search
-
-
-
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index ae66a87c..613c25d7 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -7,17 +7,17 @@ class ToolChangeRequirementInformation(models.TransientModel):
# tool_change_to_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', string='机床换刀申请')
- name = fields.Char(string='CNC机床', readonly=True)
+ name = fields.Many2one('sf.machine_tool', 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_name_id = fields.Many2one('sf.functional.cutting.tool', string='待换刀具名称')
+ replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换刀具类型')
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
string='粗/中/精')
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧')
- applicant = fields.Char(string='申请人')
+ applicant = fields.Char(string='申请人', default=lambda self: self.env.user.name, readonly=True)
used_tool_time = fields.Datetime(string='用刀时间')
reason_for_applying = fields.Char(string='申请原因')
remark = fields.Char(string='备注说明')
@@ -29,12 +29,12 @@ class ToolChangeRequirementInformation(models.TransientModel):
"""
# 封装数据
desc = {
- 'name': self.name,
+ 'name': self.name.id,
'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_name_id': self.replacement_tool_name_id.id,
+ 'replacement_tool_type_id': self.replacement_tool_type_id.id,
'replacement_tool_coarse_middle_thin': self.replacement_tool_coarse_middle_thin,
'new_former': self.new_former,
'applicant': self.applicant,
@@ -51,13 +51,13 @@ class ToolChangeRequirementInformation(models.TransientModel):
# 功能刀具组装创建新任务
self.env['sf.machine.table.tool.changing.apply'].new_assembly_task({
'functional_tool_code': self.replacement_tool_code,
- 'name': self.replacement_tool_name,
- 'functional_tool_type': self.replacement_tool_type,
+ 'name': self.replacement_tool_name_id.id,
+ 'functional_tool_type_id': self.replacement_tool_type_id.id,
'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.name,
+ 'machine_tool_name_id': self.name.id,
'machine_tool_code': self.machine_tool_code,
'cutter_spacing_code': self.cutter_spacing_code
})
@@ -70,18 +70,18 @@ class ToolTransferRequestInformation(models.TransientModel):
_name = 'sf.tool.transfer.request.information'
_description = '刀具转移申请信息'
- CNC_machine_table = fields.Char(string='CNC机床', readonly=True)
+ CNC_machine_table_id = fields.Many2one('sf.machine_tool', 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)
+ functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
# todo 功能刀具类型为 Many2one
- functional_tool_type = fields.Char(string='功能刀具类型', readonly=True)
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
transfer_target = fields.Selection([('机台', '机台'),
('线边刀库', '线边刀库'),
('刀具房', '刀具房')], string='转移到:', default='线边刀库')
- new_cnc_machine_table = fields.Char(string='机床名称')
+ new_cnc_machine_table_id = fields.Many2one('sf.machine_tool', string='机床名称')
new_machine_tool_code = fields.Char(string='机床号')
new_cutter_spacing_code = fields.Char(string='刀位号')
@@ -97,63 +97,7 @@ 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):
- _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)
-
- 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,
- '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'}
+ [('name', '=', self.CNC_machine_table_id.id)]).write({'status': '2'})
class FunctionalToolAssemblyOrder(models.TransientModel):
@@ -161,10 +105,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
_description = '功能刀具组装单'
# 功能刀具申请信息
- machine_tool_name = fields.Char(string='机床名称', readonly=True)
+ machine_tool_name_id = fields.Many2one('sf.machine_tool', string='机床名称', readonly=True)
cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
- functional_tool_name = fields.Char(string='功能刀具名称', readonly=True)
- functional_tool_type = fields.Char(string='功能刀具类型', readonly=True)
+ functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
functional_tool_length = fields.Char(string='功能刀具伸出长', readonly=True)
effective_length = fields.Char(string='有效长', readonly=True)
functional_tool_diameter = fields.Char(string='功能刀具直径', readonly=True)
@@ -196,7 +140,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
:return:
"""
self.env['sf.functional.tool.assembly'].search([
- ('machine_tool_name', '=', self.machine_tool_name),
+ ('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code', '=', self.cutter_spacing_code)
]).write({
'tool_name': self.tool_name,
@@ -227,8 +171,8 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
order = fields.Integer(string='序')
functional_tool_code = fields.Char(string='功能刀具编码')
- name = fields.Char(string='功能刀具名称')
- functional_tool_type = fields.Char(string='功能刀具类型')
+ name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称')
+ functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
production_line_name = fields.Char(string='产线名称')
machine_tool_code = fields.Char(string='机台号')
receive_person = fields.Char(string='领用人')
@@ -244,7 +188,7 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
for val in vals:
self.env['sf.functional.tool.assembly'].search([
('functional_tool_code', '=', val.functional_tool_code),
- ('name', '=', val.name)
+ ('name', '=', val.name.id)
]).write({
'assemble_status': '2',
'receive_person': self.env.user.name,
@@ -253,13 +197,13 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
tool_assembly = self.env['sf.functional.tool.assembly'].search([
('functional_tool_code', '=', val.functional_tool_code),
- ('name', '=', val.name)
+ ('name', '=', val.name.id)
])
# 判断装刀任务来源,如果来源于CAM装刀,则修改CAM装刀的计划执行状态
if tool_assembly.loading_task_source == '0':
self.env['sf.cam.work.order.program.knife.plan'].search([
('functional_tool_code', '=', val.functional_tool_code),
- ('functional_tool_name', '=', val.name)
+ ('functional_tool_name_id', '=', val.name.id)
]).write({
'plan_execute_status': '2'
})
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index d56e73b2..0d26bde2 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -20,25 +20,17 @@
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
@@ -69,7 +61,7 @@
-
+
@@ -78,8 +70,8 @@
-
-
+
+
@@ -92,7 +84,7 @@
-
+
@@ -120,67 +112,6 @@
-
-
- 申请装刀
- sf.apply.for.tooling
-
-
-
-
-
-
- 申请装刀
- ir.actions.act_window
- sf.apply.for.tooling
- form
-
- new
-
-
-
功能刀具组装单
@@ -190,8 +121,8 @@
-
-
+
+
@@ -199,7 +130,7 @@
-
+
@@ -267,7 +198,7 @@
-
+
From 6c001b6950e0ac807ae00965017fa7d428141b79 Mon Sep 17 00:00:00 2001
From: yuxianghui <1608204036@qq.com>
Date: Wed, 2 Aug 2023 17:29:02 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=AE=A1=E7=90=86-=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9?=
=?UTF-8?q?=E6=96=99=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85=E5=AE=8C=E6=88=90?=
=?UTF-8?q?=E6=97=B6=E6=96=B0=E5=BB=BA=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E3=80=81=E9=A2=84=E8=AD=A6=E3=80=81=E5=AE=9E?=
=?UTF-8?q?=E6=97=B6=E5=88=86=E5=B8=83=E3=80=81=E5=87=BA=E5=85=A5=E5=BA=93?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/__manifest__.py | 2 +-
sf_tool_management/models/base.py | 118 ++++++++++++-----
sf_tool_management/views/tool_base_views.xml | 49 ++++++--
sf_tool_management/wizard/wizard.py | 122 +++++++++++++++---
sf_tool_management/wizard/wizard_view.xml | 126 ++++++++++++++-----
5 files changed, 326 insertions(+), 91 deletions(-)
diff --git a/sf_tool_management/__manifest__.py b/sf_tool_management/__manifest__.py
index c6ec3191..10813c3d 100644
--- a/sf_tool_management/__manifest__.py
+++ b/sf_tool_management/__manifest__.py
@@ -10,7 +10,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
- 'depends': ['account', 'sf_base', 'mrp'],
+ 'depends': ['account', 'sf_base', 'mrp', 'sf_manufacturing'],
'data': [
#'security/group_security.xml',
'security/ir.model.access.csv',
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 2c7ddf30..7f8b9323 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -393,7 +393,7 @@ class MachineTableToolChangingApply(models.Model):
# 撤回功能刀具组装创建的任务
self.env['sf.functional.tool.assembly'].search(
[('functional_tool_code', '=', self.replacement_tool_code),
- ('loading_task_source', '=', '机台换刀')]).unlink()
+ ('loading_task_source', '=', '1')]).unlink()
# 撤回数据更新
self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name.id)]).write({
@@ -444,7 +444,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
need_knife_time = fields.Datetime(string='需要用刀时间', readonly=False)
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
string='计划执行状态', default='0', readonly=False)
- applicant = fields.Char(string='申请人', readonly=False)
+ applicant = fields.Char(string='申请人', readonly=True)
reason_for_applying = fields.Char(string='申请原因', readonly=False)
remark = fields.Char(string='备注说明', readonly=False)
@@ -462,7 +462,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'loading_task_source': '0',
'coarse_middle_thin': None,
'tool_loading_length': None,
- 'applicant': self.applicant,
+ 'applicant': self.env.user.name,
'reason_for_applying': self.reason_for_applying,
'use_tool_time': self.need_knife_time,
'machine_tool_name_id': self.machine_table_name_id.id,
@@ -472,7 +472,8 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
# 将计划执行状态改为执行中
self.env['sf.cam.work.order.program.knife.plan'].search(
- [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1'})
+ [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '1',
+ 'applicant': self.env.user.name})
def revocation(self):
@@ -480,13 +481,16 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
撤回装刀申请
:return:
"""
+
+
self.env['sf.functional.tool.assembly'].search(
[('functional_tool_code', '=', self.functional_tool_code),
- ('loading_task_source', '=', 'CAM装刀')]).unlink()
+ ('loading_task_source', '=', '0')]).unlink()
# 将计划执行状态改为待执行
self.env['sf.cam.work.order.program.knife.plan'].search(
- [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '0'})
+ [('functional_tool_code', '=', self.functional_tool_code)]).write({'plan_execute_status': '0',
+ 'applicant': None})
@@ -504,19 +508,58 @@ class FunctionalToolAssembly(models.Model):
functional_tool_length = fields.Char(string='功能刀具伸出长', readonly=True)
functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
- tool_name = fields.Char(string='刀具名称', readonly=False)
- tool_brand = fields.Char(string='品牌', readonly=False)
- tool_type = fields.Char(string='型号', readonly=False)
- knife_handle_name = fields.Char(string='刀柄名称', readonly=False)
- knife_handle_brand = fields.Char(string='品牌', readonly=False)
- knife_handle_type = fields.Char(string='型号', readonly=False)
- coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
- tool_loading_length = fields.Char(string='装刀长', readonly=False)
- new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=False)
- reference_length = fields.Char(string='参考伸出长', readonly=False)
- cut_time = fields.Char(string='已切削时间', readonly=False)
- cut_length = fields.Char(string='已切削长度', readonly=False)
- cut_number = fields.Char(string='已切削次数', readonly=False)
+ # 整体式刀具型号
+ mrs_cutting_tool_integral_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='整体式刀具型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '整体式刀具')])
+ integral_code = fields.Char('整体式刀具序列号', readonly=True)
+ integral_name = fields.Char('整体式刀具名称', readonly=True)
+ sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', '整体式刀具品牌', readonly=True)
+ # 刀片型号
+ mrs_cutting_tool_blade_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='刀片型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀片')])
+ blade_code = fields.Char('刀片序列号', readonly=True)
+ blade_name = fields.Char('刀片名称', readonly=True)
+ sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
+ # 刀杆型号
+ mrs_cutting_tool_cutterbar_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='刀杆型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀杆')])
+ bar_code = fields.Char('刀杆序列号', readonly=True)
+ bar_name = fields.Char('刀杆名称', readonly=True)
+ sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
+ # 刀盘型号
+ mrs_cutting_tool_cutterpad_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='刀盘型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀盘')])
+ pad_code = fields.Char('刀盘序列号', readonly=True)
+ pad_name = fields.Char('刀盘名称', readonly=True)
+ sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
+
+ # 刀柄型号
+ mrs_cutting_tool_cutterhandle_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='刀柄型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀柄')])
+ handle_code = fields.Char('刀柄序列号', readonly=True)
+ handle_name = fields.Char('刀柄名称', readonly=True)
+ sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
+ # 夹头型号
+ mrs_cutting_tool_cutterhead_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_id',
+ string='夹头型号', readonly=True, domain=
+ [('mrs_cutting_tool_material_name', '=', '夹头')])
+ chuck_code = fields.Char('夹头序列号', readonly=True)
+ chuck_name = fields.Char('夹头名称', readonly=True)
+ sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
+
+
+ coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True)
+ tool_loading_length = fields.Char(string='装刀长', readonly=True)
+ new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True)
+ reference_length = fields.Char(string='参考伸出长', readonly=True)
+ cut_time = fields.Char(string='已切削时间', readonly=True)
+ cut_length = fields.Char(string='已切削长度', readonly=True)
+ cut_number = fields.Char(string='已切削次数', readonly=True)
loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True)
applicant = fields.Char(string='申请人', readonly=True)
@@ -524,7 +567,7 @@ class FunctionalToolAssembly(models.Model):
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')],string='组装状态', default='0', readonly=True)
use_tool_time = fields.Datetime(string='用刀时间', readonly=True)
- production_line_name = fields.Char(string='产线名称', readonly=False)
+ production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False)
machine_tool_name_id = fields.Many2one('sf.machine_tool', string='机床名称', readonly=True)
machine_tool_code = fields.Char(string='机台号', readonly=True)
cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
@@ -552,12 +595,30 @@ class FunctionalToolAssembly(models.Model):
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code', '=', self.cutter_spacing_code)
]).write({
- 'tool_name': None,
- 'tool_brand': None,
- 'tool_type': None,
- 'knife_handle_name': None,
- 'knife_handle_brand': None,
- 'knife_handle_type': None,
+ 'mrs_cutting_tool_integral_model_ids': None,
+ 'integral_code': None,
+ 'integral_name': None,
+ 'sf_tool_brand_id_1': None,
+ 'mrs_cutting_tool_blade_model_ids': None,
+ 'blade_code': None,
+ 'blade_name': None,
+ 'sf_tool_brand_id_2': None,
+ 'mrs_cutting_tool_cutterbar_model_ids': None,
+ 'bar_code': None,
+ 'bar_name': None,
+ 'sf_tool_brand_id_3': None,
+ 'mrs_cutting_tool_cutterpad_model_ids': None,
+ 'pad_code': None,
+ 'pad_name': None,
+ 'sf_tool_brand_id_4': None,
+ 'mrs_cutting_tool_cutterhandle_model_ids': None,
+ 'handle_code': None,
+ 'handle_name': None,
+ 'sf_tool_brand_id_5': None,
+ 'mrs_cutting_tool_cutterhead_model_ids': None,
+ 'chuck_code': None,
+ 'chuck_name': None,
+ 'sf_tool_brand_id_6': None,
'coarse_middle_thin': None,
'tool_loading_length': None,
'new_former': None,
@@ -579,14 +640,13 @@ class FunctionalToolAssembly(models.Model):
self.env['sf.delivery.of.cargo.from.storage'].search([]).unlink()
vals = self.env['sf.functional.tool.assembly'].search([('check_box_1', '=', True),('assemble_status', '=', '1')])
-
if vals:
for val in vals:
self.env['sf.delivery.of.cargo.from.storage'].create({
'functional_tool_code': val.functional_tool_code,
'name': val.name.id,
'functional_tool_type_id': val.functional_tool_type_id.id,
- 'production_line_name': val.production_line_name,
+ 'production_line_name_id': val.production_line_name_id.id,
'machine_tool_code': val.machine_tool_code,
'receive_person': val.receive_person,
'receive_time': val.receive_time
@@ -596,7 +656,7 @@ class FunctionalToolAssembly(models.Model):
'functional_tool_code': self.functional_tool_code,
'name': self.name.id,
'functional_tool_type_id': self.functional_tool_type_id.id,
- 'production_line_name': self.production_line_name,
+ 'production_line_name_id': self.production_line_name_id.id,
'machine_tool_code': self.machine_tool_code,
'receive_person': self.receive_person,
'receive_time': self.receive_time
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index becab19c..298ae51c 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -9,14 +9,13 @@
-
+
-
@@ -824,6 +823,7 @@
type="action"
context="{
'default_machine_tool_name_id': machine_tool_name_id,
+ 'default_code': functional_tool_code,
'default_cutter_spacing_code': cutter_spacing_code,
'default_functional_tool_name_id': name,
'default_functional_tool_type_id': functional_tool_type_id,
@@ -853,6 +853,7 @@
type="action"
context="{
'default_machine_tool_name_id': machine_tool_name_id,
+ 'default_code': functional_tool_code,
'default_cutter_spacing_code': cutter_spacing_code,
'default_functional_tool_name_id': name,
'default_functional_tool_type_id': functional_tool_type_id,
@@ -887,28 +888,52 @@
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 613c25d7..7afdd536 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -106,6 +106,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 功能刀具申请信息
machine_tool_name_id = fields.Many2one('sf.machine_tool', string='机床名称', readonly=True)
+ code = fields.Char(string='功能刀具编码', readonly=True)
cutter_spacing_code = fields.Char(string='刀位号', readonly=True)
functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True)
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
@@ -118,14 +119,50 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True)
# 功能刀具组装信息
- tool_name = fields.Char(string='刀具名称')
- tool_code = fields.Char(string='刀具编码')
- tool_brand = fields.Char(string='品牌')
- tool_type = fields.Char(string='型号')
- knife_handle_name = fields.Char(string='刀柄名称')
- knife_handle_code = fields.Char(string='刀柄编码')
- knife_handle_brand = fields.Char(string='品牌')
- knife_handle_type = fields.Char(string='型号')
+ # 整体式刀具型号
+ mrs_cutting_tool_integral_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='整体式刀具型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '整体式刀具')])
+ integral_code = fields.Char('整体式刀具序列号')
+ integral_name = fields.Char('整体式刀具名称')
+ sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', '整体式刀具品牌')
+ # 刀片型号
+ mrs_cutting_tool_blade_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='刀片型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀片')])
+ blade_code = fields.Char('刀片序列号')
+ blade_name = fields.Char('刀片名称')
+ sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌')
+ # 刀杆型号
+ mrs_cutting_tool_cutterbar_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='刀杆型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀杆')])
+ bar_code = fields.Char('刀杆序列号')
+ bar_name = fields.Char('刀杆名称')
+ sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌')
+ # 刀盘型号
+ mrs_cutting_tool_cutterpad_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='刀盘型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀盘')])
+ pad_code = fields.Char('刀盘序列号')
+ pad_name = fields.Char('刀盘名称')
+ sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌')
+
+ # 刀柄型号
+ mrs_cutting_tool_cutterhandle_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='刀柄型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '刀柄')])
+ handle_code = fields.Char('刀柄序列号')
+ handle_name = fields.Char('刀柄名称')
+ sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌')
+ # 夹头型号
+ mrs_cutting_tool_cutterhead_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_tool_assembly_order_id',
+ string='夹头型号', readonly=False, domain=
+ [('mrs_cutting_tool_material_name', '=', '夹头')])
+ chuck_code = fields.Char('夹头序列号')
+ chuck_name = fields.Char('夹头名称')
+ sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌')
+
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精')
tool_loading_length = fields.Char(string='装刀长')
new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧')
@@ -143,12 +180,30 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code', '=', self.cutter_spacing_code)
]).write({
- 'tool_name': self.tool_name,
- 'tool_brand': self.tool_brand,
- 'tool_type': self.tool_type,
- 'knife_handle_name': self.knife_handle_name,
- 'knife_handle_brand': self.knife_handle_brand,
- 'knife_handle_type': self.knife_handle_type,
+ 'mrs_cutting_tool_integral_model_ids': self.mrs_cutting_tool_integral_model_ids.ids,
+ 'integral_code': self.integral_code,
+ 'integral_name': self.integral_name,
+ 'sf_tool_brand_id_1': self.sf_tool_brand_id_1,
+ 'mrs_cutting_tool_blade_model_ids': self.mrs_cutting_tool_blade_model_ids.ids,
+ 'blade_code': self.blade_code,
+ 'blade_name': self.blade_name,
+ 'sf_tool_brand_id_2': self.sf_tool_brand_id_2,
+ 'mrs_cutting_tool_cutterbar_model_ids': self.mrs_cutting_tool_cutterbar_model_ids.ids,
+ 'bar_code': self.bar_code,
+ 'bar_name': self.bar_name,
+ 'sf_tool_brand_id_3': self.sf_tool_brand_id_3,
+ 'mrs_cutting_tool_cutterpad_model_ids': self.mrs_cutting_tool_cutterpad_model_ids.ids,
+ 'pad_code': self.pad_code,
+ 'pad_name': self.pad_name,
+ 'sf_tool_brand_id_4': self.sf_tool_brand_id_4,
+ 'mrs_cutting_tool_cutterhandle_model_ids': self.mrs_cutting_tool_cutterhandle_model_ids.ids,
+ 'handle_code': self.handle_code,
+ 'handle_name': self.handle_name,
+ 'sf_tool_brand_id_5': self.sf_tool_brand_id_5,
+ 'mrs_cutting_tool_cutterhead_model_ids': self.mrs_cutting_tool_cutterhead_model_ids.ids,
+ 'chuck_code': self.chuck_code,
+ 'chuck_name': self.chuck_name,
+ 'sf_tool_brand_id_6': self.sf_tool_brand_id_6,
'coarse_middle_thin': self.coarse_middle_thin,
'tool_loading_length': self.tool_loading_length,
'new_former': self.new_former,
@@ -161,6 +216,38 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'tool_loading_time': fields.Datetime.now()
})
+ # 封装功能刀具数据
+ desc = {
+ 'code': self.code,
+ 'name': self.functional_tool_name_id.name,
+ 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id,
+ 'mrs_cutting_tool_integral_model_ids': self.mrs_cutting_tool_integral_model_ids.ids,
+ 'mrs_cutting_tool_blade_model_ids': self.mrs_cutting_tool_blade_model_ids.ids,
+ 'mrs_cutting_tool_cutterbar_model_ids': self.mrs_cutting_tool_cutterbar_model_ids.ids,
+ 'mrs_cutting_tool_cutterpad_model_ids': self.mrs_cutting_tool_cutterpad_model_ids.ids,
+ 'mrs_cutting_tool_cutterhandle_model_ids': self.mrs_cutting_tool_cutterhandle_model_ids.ids,
+ 'mrs_cutting_tool_cutterhead_model_ids': self.mrs_cutting_tool_cutterhead_model_ids.ids,
+ 'diameter': self.functional_tool_diameter,
+ 'tool_grade': None,
+ 'machining_accuracy': None,
+ 'tool_length': self.tool_loading_length,
+ 'blade_number': None,
+ 'integral_blade_length': None,
+ 'effective_blade_length': self.effective_length,
+ 'max_life': None,
+ 'is_standard': self.whether_standard_tool,
+ 'applicable_range': None,
+ 'image': None,
+ }
+
+ if self.new_former == '0':
+ # 如果是新刀,则创建功能刀具列表、
+ self.env['sf.functional.cutting.tool.entity'].create(desc)
+ # 创建功能刀具预警、实时分布、出入库记录的新记录
+ self.env['sf.functional.tool.warning'].create(desc)
+ self.env['sf.real.time.distribution.of.functional.tools'].create(desc)
+ self.env['sf.inbound.and.outbound.records.of.functional.tools'].create(desc)
+
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
@@ -173,7 +260,7 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
functional_tool_code = fields.Char(string='功能刀具编码')
name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
- production_line_name = fields.Char(string='产线名称')
+ production_line_name_id = fields.Many2one('sf.production.line', string='产线名称')
machine_tool_code = fields.Char(string='机台号')
receive_person = fields.Char(string='领用人')
receive_time = fields.Datetime(string='领用出库时间')
@@ -184,11 +271,14 @@ class DeliveryOfCargoFromStorage(models.TransientModel):
:return:
"""
vals = self.env['sf.delivery.of.cargo.from.storage'].search([])
+ print(vals)
if vals:
for val in vals:
self.env['sf.functional.tool.assembly'].search([
('functional_tool_code', '=', val.functional_tool_code),
- ('name', '=', val.name.id)
+ ('machine_tool_code', '=', val.machine_tool_code),
+ ('name', '=', val.name.id),
+ ('production_line_name_id', '=', val.production_line_name_id.id)
]).write({
'assemble_status': '2',
'receive_person': self.env.user.name,
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index 0d26bde2..5f156eae 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -122,11 +122,11 @@
+
-
@@ -134,40 +134,100 @@
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+