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 @@
-
+
+