1、功能刀具组装完成时,自动生成内部调拨单以及所有的刀具物料的库存移动和移动历史记录,并自动完成该调拨单;优化功能刀具的刀具组装入库单的生成,简化入库步骤。
This commit is contained in:
@@ -174,7 +174,7 @@
|
|||||||
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
|
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
|
||||||
<field name="current_location_id" string="当前位置"/>
|
<field name="current_location_id" string="当前位置" invisible="1"/>
|
||||||
<field name="current_location" string="当前位置"/>
|
<field name="current_location" string="当前位置"/>
|
||||||
<field name="current_shelf_location_id" string="当前货位"
|
<field name="current_shelf_location_id" string="当前货位"
|
||||||
attrs="{'invisible': [('current_shelf_location_id', '=', False)]}"/>
|
attrs="{'invisible': [('current_shelf_location_id', '=', False)]}"/>
|
||||||
|
|||||||
@@ -621,26 +621,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
desc_1 = self.get_desc_1(stock_lot)
|
desc_1 = self.get_desc_1(stock_lot)
|
||||||
# 封装功能刀具数据,用于创建功能刀具记录
|
# 封装功能刀具数据,用于创建功能刀具记录
|
||||||
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
|
||||||
# 创建刀具组装入库单
|
# 创建功能刀具组装入库单
|
||||||
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
|
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
|
||||||
# 刀具物料出库
|
# 创建刀具物料出库单
|
||||||
if self.handle_code_id:
|
self.env['stock.picking'].create_stocking_picking1(self)
|
||||||
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
|
|
||||||
if self.integral_product_id:
|
|
||||||
self.integral_product_id.material_stock_moves(self.integral_freight_barcode_id,
|
|
||||||
self.integral_freight_lot_id, self.assembly_order_code)
|
|
||||||
if self.blade_product_id:
|
|
||||||
self.blade_product_id.material_stock_moves(self.blade_freight_barcode_id,
|
|
||||||
self.blade_freight_lot_id, self.assembly_order_code)
|
|
||||||
if self.bar_product_id:
|
|
||||||
self.bar_product_id.material_stock_moves(self.bar_freight_barcode_id,
|
|
||||||
self.bar_freight_lot_id, self.assembly_order_code)
|
|
||||||
if self.pad_product_id:
|
|
||||||
self.pad_product_id.material_stock_moves(self.pad_freight_barcode_id,
|
|
||||||
self.pad_freight_lot_id, self.assembly_order_code)
|
|
||||||
if self.chuck_product_id:
|
|
||||||
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode_id,
|
|
||||||
self.chuck_freight_lot_id, self.assembly_order_code)
|
|
||||||
|
|
||||||
# ============================创建功能刀具列表、安全库存记录===============================
|
# ============================创建功能刀具列表、安全库存记录===============================
|
||||||
# 创建功能刀具列表记录
|
# 创建功能刀具列表记录
|
||||||
@@ -788,7 +772,7 @@ class StockPicking(models.Model):
|
|||||||
|
|
||||||
def create_stocking_picking(self, stock_lot, functional_tool_assembly, obj):
|
def create_stocking_picking(self, stock_lot, functional_tool_assembly, obj):
|
||||||
"""
|
"""
|
||||||
创建刀具组装入库单
|
创建功能刀具组装入库单
|
||||||
"""
|
"""
|
||||||
# 获取名称为刀具组装入库的作业类型
|
# 获取名称为刀具组装入库的作业类型
|
||||||
picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')])
|
picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '刀具组装入库')])
|
||||||
@@ -807,6 +791,7 @@ class StockPicking(models.Model):
|
|||||||
'location_id': picking_id.location_id.id,
|
'location_id': picking_id.location_id.id,
|
||||||
'location_dest_id': picking_id.location_dest_id.id,
|
'location_dest_id': picking_id.location_dest_id.id,
|
||||||
'lot_id': stock_lot.id,
|
'lot_id': stock_lot.id,
|
||||||
|
'install_tool_time': fields.Datetime.now(),
|
||||||
'qty_done': 1,
|
'qty_done': 1,
|
||||||
'functional_tool_name_id': functional_tool_assembly.id,
|
'functional_tool_name_id': functional_tool_assembly.id,
|
||||||
'functional_tool_type_id': obj.functional_tool_type_id.id,
|
'functional_tool_type_id': obj.functional_tool_type_id.id,
|
||||||
@@ -836,6 +821,65 @@ class StockPicking(models.Model):
|
|||||||
num = "%03d" % m
|
num = "%03d" % m
|
||||||
return name + str(num)
|
return name + str(num)
|
||||||
|
|
||||||
|
def create_stocking_picking1(self, obj):
|
||||||
|
"""
|
||||||
|
创建刀具物料出库单
|
||||||
|
"""
|
||||||
|
# 获取名称为内部调拨的作业类型
|
||||||
|
picking_type_id = self.env['stock.picking.type'].sudo().search([('name', '=', '内部调拨')])
|
||||||
|
# 创建刀具物料出库单
|
||||||
|
picking_id = self.env['stock.picking'].create({
|
||||||
|
'name': self._get_name_stock1(picking_type_id),
|
||||||
|
'picking_type_id': picking_type_id.id,
|
||||||
|
'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id,
|
||||||
|
'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id,
|
||||||
|
'origin': obj.assembly_order_code
|
||||||
|
})
|
||||||
|
# =============刀具物料出库===================
|
||||||
|
product_id = self.env['product.product']
|
||||||
|
datas = {'data': [], 'picking_id': picking_id}
|
||||||
|
if obj.handle_code_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': self.env['sf.shelf.location'], 'lot_id': obj.handle_code_id})
|
||||||
|
if obj.integral_product_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': obj.integral_freight_barcode_id, 'lot_id': obj.integral_freight_lot_id.lot_id})
|
||||||
|
if obj.blade_product_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': obj.blade_freight_barcode_id, 'lot_id': obj.blade_freight_lot_id.lot_id})
|
||||||
|
if obj.bar_product_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': obj.bar_freight_barcode_id, 'lot_id': obj.bar_freight_lot_id.lot_id})
|
||||||
|
if obj.pad_product_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': obj.pad_freight_barcode_id, 'lot_id': obj.pad_freight_lot_id.lot_id})
|
||||||
|
if obj.chuck_product_id:
|
||||||
|
datas['data'].append(
|
||||||
|
{'current_location_id': obj.chuck_freight_barcode_id, 'lot_id': obj.chuck_freight_lot_id.lot_id})
|
||||||
|
# 创建刀具物料出库库存移动记录
|
||||||
|
product_id.create_tool_material_stock_moves(datas)
|
||||||
|
# 将刀具物料出库库单的状态更改为就绪
|
||||||
|
picking_id.action_confirm()
|
||||||
|
# 修改刀具物料出库移动历史记录
|
||||||
|
product_id.write_tool_material_stock_move_lines(datas)
|
||||||
|
# 设置数量,并验证完成
|
||||||
|
picking_id.action_set_quantities_to_reservation()
|
||||||
|
picking_id.button_validate()
|
||||||
|
|
||||||
|
def _get_name_stock1(self, picking_type_id):
|
||||||
|
name = picking_type_id.sequence_id.prefix
|
||||||
|
stock_id = self.env['stock.picking'].sudo().search(
|
||||||
|
[('name', 'like', name), ('picking_type_id', '=', picking_type_id.id)],
|
||||||
|
limit=1,
|
||||||
|
order="id desc"
|
||||||
|
)
|
||||||
|
if not stock_id:
|
||||||
|
num = "%03d" % 1
|
||||||
|
else:
|
||||||
|
m = int(stock_id.name[-3:]) + 1
|
||||||
|
num = "%03d" % m
|
||||||
|
return name + str(num)
|
||||||
|
|
||||||
|
|
||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
@@ -853,13 +897,6 @@ class ProductProduct(models.Model):
|
|||||||
'product_id': product_id[0].id,
|
'product_id': product_id[0].id,
|
||||||
'company_id': self.env.company.id
|
'company_id': self.env.company.id
|
||||||
})
|
})
|
||||||
# 获取位置对象
|
|
||||||
location_inventory_ids = self.env['stock.location'].search([('name', 'in', ('Production', '生产'))])
|
|
||||||
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
|
|
||||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
|
||||||
stock_lot.create_stock_quant(location_inventory_ids[-1], stock_location_id, functional_tool_assembly.id,
|
|
||||||
obj.assembly_order_code, obj, obj.after_tool_groups_id)
|
|
||||||
|
|
||||||
return stock_lot
|
return stock_lot
|
||||||
|
|
||||||
def get_stock_lot_name(self, obj):
|
def get_stock_lot_name(self, obj):
|
||||||
@@ -878,39 +915,37 @@ class ProductProduct(models.Model):
|
|||||||
num = "%03d" % m
|
num = "%03d" % m
|
||||||
return '%s-%s' % (code, num)
|
return '%s-%s' % (code, num)
|
||||||
|
|
||||||
def tool_material_stock_moves(self, tool_material, assembly_order_code):
|
def create_tool_material_stock_moves(self, datas):
|
||||||
"""
|
picking_id = datas['picking_id']
|
||||||
对刀具物料进行库存移动到 刀具组装位置
|
data = datas['data']
|
||||||
"""
|
stock_move_ids = []
|
||||||
# 获取位置对象
|
for res in data:
|
||||||
location_inventory_id = tool_material.quant_ids.location_id[-1]
|
if res:
|
||||||
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
# 创建库存移动记录
|
||||||
# 创建功能刀具该批次/序列号 库存移动和移动历史
|
stock_move_id = self.env['stock.move'].sudo().create({
|
||||||
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
|
'name': picking_id.name,
|
||||||
False)
|
'picking_id': picking_id.id,
|
||||||
|
'product_id': res['lot_id'].product_id.id,
|
||||||
|
'location_id': picking_id.location_id.id,
|
||||||
|
'location_dest_id': picking_id.location_dest_id.id,
|
||||||
|
'product_uom_qty': 1.00,
|
||||||
|
'reserved_availability': 1.00
|
||||||
|
})
|
||||||
|
stock_move_ids.append(stock_move_id)
|
||||||
|
return stock_move_ids
|
||||||
|
|
||||||
def material_stock_moves(self, shelf_location_barcode_id, lot_id, assembly_order_code):
|
def write_tool_material_stock_move_lines(self, datas):
|
||||||
# 创建库存移动记录
|
picking_id = datas['picking_id']
|
||||||
stock_move_id = self.env['stock.move'].sudo().create({
|
data = datas['data']
|
||||||
'name': assembly_order_code,
|
move_line_ids = picking_id.move_line_ids
|
||||||
'product_id': self.id,
|
for move_line_id in move_line_ids:
|
||||||
'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id,
|
for res in data:
|
||||||
'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id,
|
if move_line_id.lot_id.product_id == res['lot_id'].product_id:
|
||||||
'product_uom_qty': 1.00,
|
move_line_id.write({
|
||||||
'state': 'done'
|
'current_location_id': res.get('current_location_id').id,
|
||||||
})
|
'lot_id': res.get('lot_id').id
|
||||||
|
})
|
||||||
# 创建移动历史记录
|
return True
|
||||||
stock_move_line_id = self.env['stock.move.line'].sudo().create({
|
|
||||||
'product_id': self.id,
|
|
||||||
'move_id': stock_move_id.id,
|
|
||||||
'lot_id': lot_id.lot_id.id,
|
|
||||||
'current_location_id': shelf_location_barcode_id.id,
|
|
||||||
'install_tool_time': fields.Datetime.now(),
|
|
||||||
'qty_done': 1.0,
|
|
||||||
'state': 'done',
|
|
||||||
})
|
|
||||||
return stock_move_id, stock_move_line_id
|
|
||||||
|
|
||||||
|
|
||||||
class StockLot(models.Model):
|
class StockLot(models.Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user