From 96c5c3dcf54ea6f61c0e0cc6ff002d3e2b3d8225 Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Fri, 22 Dec 2023 17:37:10 +0800
Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E6=8C=89?=
=?UTF-8?q?=E7=85=A7=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=AE=89=E5=85=A8?=
=?UTF-8?q?=E5=BA=93=E5=AD=98=E6=95=B0=E9=87=8F=E8=87=AA=E5=8A=A8=E8=A7=A6?=
=?UTF-8?q?=E5=8F=91=E5=88=9B=E5=BB=BA=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?=
=?UTF-8?q?=E7=BB=84=E8=A3=85=E5=8D=95=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_tool_management/models/base.py | 41 ++++++++++++++++++++
sf_tool_management/views/tool_base_views.xml | 9 +++--
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 3a919de7..251e20c0 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -293,6 +293,9 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
'sf_functional_cutting_tool_entity_ref',
string='功能刀具列表信息', readonly=True)
+ sf_functional_tool_assembly_ids = fields.Many2many('sf.functional.tool.assembly', 'sf_functional_tool_assembly_ref',
+ '功能刀具组装单', readonly=True)
+
@api.model
def _read_mrs_cutting_tool_type_ids(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
@@ -302,15 +305,50 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
def _compute_batch_replenishment_num(self):
for tool in self:
if tool:
+ # 判断功能刀具组装单是否已经完成
+ tool.estimate_functional_tool_assembly_ids(tool)
tool.get_stock_num(tool)
# 计算当前库存量
tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
if tool.tool_stock_total < tool.min_stock_num:
tool.batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
+ # 根据判断创建功能刀具组装单
+ if not tool.sf_functional_tool_assembly_ids:
+ for i in range(tool.batch_replenishment_num):
+ tool.create_functional_tool_assembly()
+ print(i, ": ", tool.sf_functional_tool_assembly_ids)
else:
tool.batch_replenishment_num = 0
+ def create_functional_tool_assembly(self):
+ """
+ 创建功能刀具组装单
+ """
+ functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({
+ 'functional_tool_name': self.name,
+ 'functional_tool_type_id': self.sf_cutting_tool_type_id.id,
+ 'functional_tool_diameter': self.diameter,
+ 'knife_tip_r_angle': self.knife_tip_r_angle,
+ 'coarse_middle_thin': self.coarse_middle_thin,
+ 'loading_task_source': '2',
+ 'use_tool_time': fields.Datetime.now() + timedelta(hours=4),
+ 'applicant': '系统自动',
+ 'apply_time': fields.Datetime.now(),
+ 'whether_standard_knife': self.whether_standard_knife,
+ 'reason_for_applying': '安全库存',
+ })
+ self.sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
+
+ def estimate_functional_tool_assembly_ids(self, tool):
+ """
+ 判断功能刀具组装单是否完成,如果全部完成清空sf_functional_tool_assembly_ids的数据
+ """
+ for sf_functional_tool_assembly_id in tool.sf_functional_tool_assembly_ids:
+ if sf_functional_tool_assembly_id.assemble_status == '0':
+ return False
+ tool.sf_functional_tool_assembly_ids = []
+
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
@@ -494,6 +532,9 @@ class MachineTableToolChangingApply(models.Model):
[('name', '=', self.name.id)]).write({'status': '0'})
def create_tool_change_application(self):
+ """
+ 根据已有机床刀位创建机台换刀申请记录
+ """
maintenance_equipment_ids = self.env['maintenance.equipment'].sudo().search(
[('product_template_ids', '!=', False)])
tool_changing_apply = self.env['sf.machine.table.tool.changing.apply']
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 68b595b0..d1f690ce 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -25,8 +25,8 @@
-
-
+
+
@@ -366,7 +366,7 @@
-
+
@@ -1158,7 +1158,8 @@
-
+
+
From e7bfff491ba422925561f4bafd3dfa5a97ae1d7e Mon Sep 17 00:00:00 2001
From: yuxianghui <3437689193@qq.com>
Date: Mon, 25 Dec 2023 15:37:14 +0800
Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=BA=93?=
=?UTF-8?q?=E5=AD=98=E4=BD=8D=E7=BD=AE=EF=BC=9A=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E4=BD=8D=E7=BD=AE=EF=BC=8C2?=
=?UTF-8?q?=E3=80=81=E5=AE=8C=E5=96=84=E6=A0=B9=E6=8D=AE=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E5=88=80=E5=85=B7=E5=AE=89=E5=85=A8=E5=BA=93=E5=AD=98=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E7=BB=84=E8=A3=85=E5=8D=95=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E3=80=823=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?=
=?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85tree=E8=A7=86=E5=9B=BE=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E9=BB=98=E8=AE=A4=E7=AD=9B=E9=80=89=E6=9C=AA=E7=BB=84?=
=?UTF-8?q?=E8=A3=85=E7=8A=B6=E6=80=81=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_dlm_management/data/stock_data.xml | 8 ++++++
sf_tool_management/models/base.py | 27 ++++++++++++--------
sf_tool_management/views/tool_base_views.xml | 9 ++++---
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/sf_dlm_management/data/stock_data.xml b/sf_dlm_management/data/stock_data.xml
index d6067cdf..3d2c4527 100644
--- a/sf_dlm_management/data/stock_data.xml
+++ b/sf_dlm_management/data/stock_data.xml
@@ -14,6 +14,14 @@
+
+ 刀具组装位置
+ internal
+ DJZZ
+ true
+
+
+
刀具组装入库
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 251e20c0..37c534da 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -301,7 +301,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
- @api.depends('sf_functional_cutting_tool_entity_ids')
+ @api.depends('sf_functional_cutting_tool_entity_ids', 'min_stock_num', 'max_stock_num')
def _compute_batch_replenishment_num(self):
for tool in self:
if tool:
@@ -311,15 +311,22 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
# 计算当前库存量
tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
- if tool.tool_stock_total < tool.min_stock_num:
- tool.batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
- # 根据判断创建功能刀具组装单
- if not tool.sf_functional_tool_assembly_ids:
- for i in range(tool.batch_replenishment_num):
- tool.create_functional_tool_assembly()
- print(i, ": ", tool.sf_functional_tool_assembly_ids)
- else:
- tool.batch_replenishment_num = 0
+ tool.open_batch_replenishment_num(tool)
+
+ def open_batch_replenishment_num(self, tool):
+ """
+ 计算批次补货量
+ """
+ if tool.tool_stock_total < tool.min_stock_num:
+ tool.batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
+ # 根据判断创建功能刀具组装单
+ if not tool.sf_functional_tool_assembly_ids:
+ for i in range(tool.batch_replenishment_num):
+ tool.create_functional_tool_assembly()
+ print(i, ": ", tool.sf_functional_tool_assembly_ids)
+ else:
+ tool.batch_replenishment_num = 0
+
def create_functional_tool_assembly(self):
"""
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index d1f690ce..6f6eb747 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -1158,11 +1158,11 @@
-
-
+
+
-
+
@@ -1173,6 +1173,9 @@
ir.actions.act_window
sf.functional.tool.assembly
tree,form,search
+
+
+ {'search_default_no_assemble_status':1}