1、功能刀具列表模型新增查询功能刀具安全库存功能;2、重构功能刀具安全库存模型;3、功能刀具组装单弹窗界面的刀具物料新增位置为刀具房的过滤筛选;

This commit is contained in:
yuxianghui
2023-11-24 17:12:44 +08:00
parent b3fbbeb85c
commit bf8b45609c
3 changed files with 211 additions and 236 deletions

View File

@@ -57,12 +57,10 @@ class ToolChangeRequirementInformation(models.TransientModel):
确认换刀申请(按键)
:return:
"""
print('已运行')
record = self.env['sf.machine.table.tool.changing.apply'].search(
[('maintenance_equipment_id', '=', self.maintenance_equipment_id.id),
('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id)
])
print('运行record_1')
# 功能刀具组装创建新任务(new_assembly_task)
sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({
@@ -86,13 +84,11 @@ class ToolChangeRequirementInformation(models.TransientModel):
'reason_for_applying': self.reason_for_applying,
'sf_machine_table_tool_changing_apply_id': record.id
})
print('sf_functional_tool_assembly:', sf_functional_tool_assembly)
# 修改机床换刀申请状态
record.write({
'status': '1',
'sf_functional_tool_assembly_id': sf_functional_tool_assembly
'sf_functional_tool_assembly_id': sf_functional_tool_assembly.id
})
print('运行成功')
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
@@ -186,7 +182,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 功能刀具组装信息
# 整体式刀具型号
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')])
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
readonly=True)
integral_name = fields.Char('整体式刀具名称', readonly=True)
@@ -194,14 +191,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 刀片型号
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片')])
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True)
blade_name = fields.Char('刀片名称', readonly=True)
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
# 刀杆型号
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')])
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
readonly=True)
bar_name = fields.Char('刀杆名称', readonly=True)
@@ -209,7 +208,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 刀盘型号
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')])
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
readonly=True)
pad_name = fields.Char('刀盘名称', readonly=True)
@@ -217,7 +217,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 刀柄型号
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')])
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
readonly=True)
handle_name = fields.Char('刀柄名称', readonly=True)
@@ -225,7 +226,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 夹头型号
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True,
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')])
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
('quant_ids.location_id.name', 'in', ['刀具房'])])
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
readonly=True)
chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
@@ -347,6 +349,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
])
# 对物料做必填判断
self.materials_must_be_judged()
# # 刀具物料出库
# if self.integral_code_id:
# print("已运行1111")
# self.tool_material_out_of_store(self.integral_code_id)
# 创建组装入库单
# 创建功能刀具批次/序列号记录
@@ -359,14 +365,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建功能刀具列表记录
# 封装功能刀具数据
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
# 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录
# 创建功能刀具列表记录
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
# self.env['sf.real.time.distribution.of.functional.tools'].create({
# 'functional_cutting_tool_id': record_1.id
# })
# self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({
# 'functional_cutting_tool_id': record_1.id
# })
# 创建安全库存信息
self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({
'name': self.after_assembly_functional_tool_name,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
'diameter': self.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle,
'coarse_middle_thin': self.after_assembly_coarse_middle_thin,
}, record_1)
# 修改功能刀具组装单信息
functional_tool_assembly.write(desc_1)
@@ -430,6 +438,38 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
return stock_lot
# def tool_material_out_of_store(self, tool_material_serial_id):
# """
# 刀具物料出库
# """
# # 获取位置
# location_id = self.env['stock.location'].search([('name', '=', 'Stock')])
# location_dest_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
# print("已运行2222")
# # 创建库存移动
# stock_move_id = self.env['stock.move'].create({
# 'name': '刀具物料出库',
# 'lot_id': tool_material_serial_id.id,
# 'product_id': tool_material_serial_id.product_id.id,
# 'location_id': location_id.id,
# 'location_dest_id': location_dest_id.id,
# 'product_uom_qty': 1.00,
# 'state': 'done'
# })
# print("已运行3333")
# print(stock_move_id)
# # 创建移动历史
# stock_move_line_id = self.env['stock.move.line'].create({
# 'product_id': tool_material_serial_id.product_id.id,
# 'lot_id': tool_material_serial_id.id,
# 'move_id': stock_move_id.id,
# 'install_tool_time': fields.Datetime.now(),
# 'qty_done': 1.0,
# 'state': 'done'
# })
#
# return stock_move_id, stock_move_line_id
def create_stock_quant(self, product_id, stock_lot, functional_tool_assembly):
"""
创建功能刀具该批次/序列号 库存移动和移动历史