1、基于原生的移动历史重构功能刀具出入库记录模型;2、功能刀具列表模型新增查询当前功能刀具出入库记录按钮;3、删除旧的功能刀具出入库记录模型和出入库记录人模型;4、机台换刀申请模型的功能刀具名称字段改为绑定功能刀具组装单;5、优化功能刀具组装单确认组装功能的创建移动历史记录功能。

This commit is contained in:
yuxianghui
2023-11-23 17:15:34 +08:00
parent ca61537e21
commit 97d760cd56
10 changed files with 110 additions and 357 deletions

View File

@@ -339,33 +339,28 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
功能刀具组装
:return:
"""
# 对物料做必填判断
self.materials_must_be_judged()
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = self.create_assemble_warehouse_receipt()
# 创建刀具组装入库单
self.create_stocking_picking(stock_lot)
# 封装功能刀具数据
desc_1 = self.get_desc_1(stock_lot)
functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([
('assembly_order_code', '=', self.assembly_order_code),
('machine_tool_name_id', '=', self.machine_tool_name_id.id),
('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id),
('assemble_status', '=', '0'),
])
# 对物料做必填判断
self.materials_must_be_judged()
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = self.create_assemble_warehouse_receipt(functional_tool_assembly)
# 创建刀具组装入库单
self.create_stocking_picking(stock_lot)
# 封装功能刀具数据
desc_1 = self.get_desc_1(stock_lot)
# 创建功能刀具列表记录
# 封装功能刀具数据
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.functional.tool.warning'].create({
# 'functional_cutting_tool_id': record_1.id,
# 'functional_tool_assembly_id': functional_tool_assembly.id,
# 'machine_table_name_id': self.machine_tool_name_id.id,
# })
# self.env['sf.real.time.distribution.of.functional.tools'].create({
# 'functional_cutting_tool_id': record_1.id
# })
@@ -419,7 +414,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 将刀具组装入库单的状态更改为就绪
picking_id.action_confirm()
def create_assemble_warehouse_receipt(self):
def create_assemble_warehouse_receipt(self, functional_tool_assembly):
"""
创建功能刀具批次/序列号记录
"""
@@ -431,11 +426,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'company_id': self.env.company.id
})
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.create_stock_quant(product_id, stock_lot)
self.create_stock_quant(product_id, stock_lot, functional_tool_assembly)
return stock_lot
def create_stock_quant(self, product_id, stock_lot):
def create_stock_quant(self, product_id, stock_lot, functional_tool_assembly):
"""
创建功能刀具该批次/序列号 库存移动和移动历史
"""
@@ -445,7 +440,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建库存移动
stock_move_id = self.env['stock.move'].create({
'name': '更新的产品数量',
'name': '功能刀具组装出库',
'product_id': product_id.id,
'location_id': location_inventory_id.id,
'location_dest_id': stock_location_id.id,
@@ -456,8 +451,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建移动历史
stock_move_line_id = self.env['stock.move.line'].create({
'product_id': product_id.id,
'functional_tool_name_id': functional_tool_assembly.id,
'lot_id': stock_lot.id,
'move_id': stock_move_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done'
})