1、新增按照功能刀具安全库存数量自动触发创建功能刀具组装单;
This commit is contained in:
@@ -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']
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
<field name="used_value"/>
|
||||
<field name="functional_tool_status"/>
|
||||
|
||||
<field name="current_location_id" invisible="True"/>
|
||||
<field name="current_location" invisible="True"/>
|
||||
<field name="current_location_id" optional="hide"/>
|
||||
<field name="current_location" optional="hide"/>
|
||||
<field name="sf_cutting_tool_type_id" invisible="True"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -366,7 +366,7 @@
|
||||
<field name="barcode_id"/>
|
||||
<field name="functional_tool_name_id"/>
|
||||
<field name="new_former"/>
|
||||
<field name="tool_loading_length"/>
|
||||
<field name="tool_loading_length" string="总长度"/>
|
||||
<field name="functional_tool_length"/>
|
||||
<field name="effective_length"/>
|
||||
<field name="max_lifetime_value"/>
|
||||
@@ -1158,7 +1158,8 @@
|
||||
<field name="applicant"/>
|
||||
<field name="apply_time"/>
|
||||
<field name="functional_tool_type_id"/>
|
||||
<field name="assemble_status"/>
|
||||
<filter name="assemble_status" string="未组装" domain="[('assemble_status', '=', '0')]"/>
|
||||
<filter name="assemble_status" string="已组装" domain="[('assemble_status', '=', '1')]"/>
|
||||
<searchpanel>
|
||||
<field name="functional_tool_type_id" enable_counters="1" icon="fa-filter"/>
|
||||
<field name="assemble_status" enable_counters="1" icon="fa-filter"/>
|
||||
|
||||
Reference in New Issue
Block a user