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] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=9C=BA=E5=8F=B0?=
=?UTF-8?q?=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E5=92=8CCAM=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=90=9C?=
=?UTF-8?q?=E7=B4=A2=E8=A7=86=E5=9B=BE=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86?=
=?UTF-8?q?=E6=9C=BA=E5=8F=B0=E6=8D=A2=E5=88=80=E7=94=B3=E8=AF=B7=E7=9A=84?=
=?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8D=A2=E5=88=80=E5=8A=9F=E8=83=BD=EF=BC=8C?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86CAM=E7=A8=8B=E5=BA=8F=E7=94=A8?=
=?UTF-8?q?=E5=88=80=E8=AE=A1=E5=88=92=E7=9A=84=E8=87=AA=E5=8A=A8=E6=8D=A2?=
=?UTF-8?q?=E5=88=80=E7=94=B3=E8=AF=B7=E5=8A=9F=E8=83=BD=EF=BC=88=E5=BE=85?=
=?UTF-8?q?=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"
/>
-
+