增加刀具管理权限控制,刀具组权限控制,隐藏工单上原生按钮,修复只读权限后修改记录无权限问题等
This commit is contained in:
@@ -44,13 +44,13 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
if record.barcode_id.quant_ids:
|
||||
for quant_id in record.barcode_id.quant_ids:
|
||||
if quant_id.inventory_quantity_auto_apply > 0:
|
||||
record.current_location_id = quant_id.location_id
|
||||
record.current_location = quant_id.location_id.name
|
||||
record.sudo().current_location_id = quant_id.location_id
|
||||
record.sudo().current_location = quant_id.location_id.name
|
||||
if record.current_location_id:
|
||||
record.get_location_num()
|
||||
record.sudo().get_location_num()
|
||||
else:
|
||||
record.current_location_id = False
|
||||
record.current_location = False
|
||||
record.sudo().current_location_id = False
|
||||
record.sudo().current_location = False
|
||||
|
||||
def get_location_num(self):
|
||||
"""
|
||||
@@ -128,24 +128,24 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
print('111')
|
||||
if record.cutting_tool_integral_model_id:
|
||||
print(record.cutting_tool_integral_model_id)
|
||||
record.suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
|
||||
record.blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
|
||||
record.handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
|
||||
record.cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
|
||||
record.suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
|
||||
record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
|
||||
record.sudo().blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
|
||||
record.sudo().handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
|
||||
record.sudo().cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
|
||||
record.sudo().suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
|
||||
print(record.cutting_tool_integral_model_id.blade_tip_characteristics_id.ids)
|
||||
elif record.cutting_tool_blade_model_id:
|
||||
record.suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
|
||||
record.blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
|
||||
record.handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
|
||||
record.cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
|
||||
record.suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
|
||||
record.sudo().suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
|
||||
record.sudo().blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
|
||||
record.sudo().handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
|
||||
record.sudo().cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
|
||||
record.sudo().suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
|
||||
else:
|
||||
record.suitable_machining_method_ids = []
|
||||
record.blade_tip_characteristics_id = None
|
||||
record.handle_type_id = None
|
||||
record.cutting_direction_ids = []
|
||||
record.suitable_coolant_ids = []
|
||||
record.sudo().suitable_machining_method_ids = []
|
||||
record.sudo().blade_tip_characteristics_id = None
|
||||
record.sudo().handle_type_id = None
|
||||
record.sudo().cutting_direction_ids = []
|
||||
record.sudo().suitable_coolant_ids = []
|
||||
|
||||
def _get_functional_tool_model_ids(self, functional_tool_model_code):
|
||||
functional_tool_model_ids = []
|
||||
@@ -310,9 +310,9 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
def _compute_name(self):
|
||||
for obj in self:
|
||||
if obj.tool_groups_id:
|
||||
obj.name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle)
|
||||
obj.sudo().name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle)
|
||||
else:
|
||||
obj.name = None
|
||||
obj.sudo().name = None
|
||||
|
||||
@api.constrains('min_stock_num', 'max_stock_num')
|
||||
def _check_stock_num(self):
|
||||
@@ -330,26 +330,26 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
for tool in self:
|
||||
if tool:
|
||||
# 判断功能刀具组装单是否已经完成
|
||||
tool.estimate_functional_tool_assembly_ids(tool)
|
||||
tool.get_stock_num(tool)
|
||||
tool.sudo().estimate_functional_tool_assembly_ids(tool)
|
||||
tool.sudo().get_stock_num(tool)
|
||||
# 计算当前库存量
|
||||
tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
|
||||
tool.sudo().tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
|
||||
# 如果当前库存量小于最低库存量,计算批次补货量
|
||||
tool.open_batch_replenishment_num(tool)
|
||||
tool.sudo().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
|
||||
tool.sudo().batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
|
||||
# 根据判断创建功能刀具组装单
|
||||
if not tool.sf_functional_tool_assembly_ids and re.match(r'^\d+$', str(tool.id)):
|
||||
for i in range(tool.batch_replenishment_num):
|
||||
tool.create_functional_tool_assembly(tool)
|
||||
tool.sudo().create_functional_tool_assembly(tool)
|
||||
print(i, ": ", tool.sf_functional_tool_assembly_ids)
|
||||
else:
|
||||
tool.batch_replenishment_num = 0
|
||||
tool.sudo().batch_replenishment_num = 0
|
||||
|
||||
def create_functional_tool_assembly(self, tool):
|
||||
"""
|
||||
@@ -369,7 +369,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
'whether_standard_knife': tool.whether_standard_knife,
|
||||
'reason_for_applying': '安全库存',
|
||||
})
|
||||
tool.sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
|
||||
tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
|
||||
|
||||
def estimate_functional_tool_assembly_ids(self, tool):
|
||||
"""
|
||||
@@ -378,24 +378,24 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||
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 = []
|
||||
tool.sudo().sf_functional_tool_assembly_ids = []
|
||||
|
||||
def get_stock_num(self, tool):
|
||||
"""
|
||||
计算刀具房数量、线边刀库数量、机内刀库数量
|
||||
"""
|
||||
if tool:
|
||||
tool.tool_stock_num = 0
|
||||
tool.side_shelf_num = 0
|
||||
tool.on_tool_stock_num = 0
|
||||
tool.sudo().tool_stock_num = 0
|
||||
tool.sudo().side_shelf_num = 0
|
||||
tool.sudo().on_tool_stock_num = 0
|
||||
if tool.sf_functional_cutting_tool_entity_ids:
|
||||
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
|
||||
if cutting_tool.tool_room_num > 0:
|
||||
tool.tool_stock_num += 1
|
||||
tool.sudo().tool_stock_num += 1
|
||||
elif cutting_tool.line_edge_knife_library_num > 0:
|
||||
tool.side_shelf_num += 1
|
||||
tool.sudo().side_shelf_num += 1
|
||||
elif cutting_tool.machine_knife_library_num > 0:
|
||||
tool.on_tool_stock_num += 1
|
||||
tool.sudo().on_tool_stock_num += 1
|
||||
|
||||
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
|
||||
"""
|
||||
@@ -480,21 +480,21 @@ class MachineTableToolChangingApply(models.Model):
|
||||
def _compute_functional_tool_status(self):
|
||||
for record in self:
|
||||
if record.alarm_value < record.used_value:
|
||||
record.functional_tool_status = '报警'
|
||||
record.sudo().functional_tool_status = '报警'
|
||||
else:
|
||||
record.functional_tool_status = '正常'
|
||||
record.sudo().functional_tool_status = '正常'
|
||||
|
||||
@api.depends('maintenance_equipment_id')
|
||||
def _compute_machine_table_type_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.production_line_id = record.maintenance_equipment_id.production_line_id.id
|
||||
record.machine_table_type_id = record.maintenance_equipment_id.category_id.id
|
||||
record.machine_tool_code = record.maintenance_equipment_id.code
|
||||
record.sudo().production_line_id = record.maintenance_equipment_id.production_line_id.id
|
||||
record.sudo().machine_table_type_id = record.maintenance_equipment_id.category_id.id
|
||||
record.sudo().machine_tool_code = record.maintenance_equipment_id.code
|
||||
else:
|
||||
record.production_line_id = None
|
||||
record.machine_table_type_id = None
|
||||
record.machine_tool_code = None
|
||||
record.sudo().production_line_id = None
|
||||
record.sudo().machine_table_type_id = None
|
||||
record.sudo().machine_tool_code = None
|
||||
|
||||
@api.constrains("cutter_spacing_code_id")
|
||||
def _check_cutter_spacing_code_id(self):
|
||||
|
||||
Reference in New Issue
Block a user