1
This commit is contained in:
@@ -776,7 +776,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
dismantle_person = fields.Char('拆解人', readonly=True)
|
||||
image = fields.Binary('图片', readonly=True)
|
||||
|
||||
scrap_id = fields.Char('报废单号', readonly=True)
|
||||
scrap_ids = fields.One2many('stock.scrap', 'functional_tool_dismantle_id', string='报废单号', readonly=True)
|
||||
grinding_id = fields.Char('磨削单号', readonly=True)
|
||||
|
||||
state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解', tracking=True)
|
||||
@@ -941,7 +941,6 @@ class FunctionalToolDismantle(models.Model):
|
||||
lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
|
||||
if not lot:
|
||||
raise ValidationError('Rfid为【%s】的功能刀具序列号不存在!' % self.handle_rfid)
|
||||
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
|
||||
if self.scrap_boolean:
|
||||
# 刀柄报废 入库到Scrap
|
||||
lot.create_stock_quant(location, location_dest_scrap_ids[-1], False, code, False, False)
|
||||
@@ -1043,3 +1042,9 @@ class ProductProduct(models.Model):
|
||||
})
|
||||
|
||||
return stock_move_id, stock_move_line_id
|
||||
|
||||
|
||||
class CustomStockScrap(models.Model):
|
||||
_inherit = 'stock.scrap'
|
||||
|
||||
functional_tool_dismantle_id = fields.Many2one('sf.functional.tool.dismantle', string="功能刀具拆解单")
|
||||
|
||||
@@ -836,7 +836,7 @@ class StockPicking(models.Model):
|
||||
'origin': obj.assembly_order_code
|
||||
})
|
||||
# =============刀具物料出库===================
|
||||
product_id = self.env['product.product']
|
||||
stock_move_id = self.env['stock.move']
|
||||
datas = {'data': [], 'picking_id': picking_id}
|
||||
if obj.handle_code_id:
|
||||
datas['data'].append(
|
||||
@@ -857,11 +857,11 @@ class StockPicking(models.Model):
|
||||
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)
|
||||
stock_move_id.create_tool_material_stock_moves(datas)
|
||||
# 将刀具物料出库库单的状态更改为就绪
|
||||
picking_id.action_confirm()
|
||||
# 修改刀具物料出库移动历史记录
|
||||
product_id.write_tool_material_stock_move_lines(datas)
|
||||
stock_move_id.write_tool_material_stock_move_lines(datas)
|
||||
# 设置数量,并验证完成
|
||||
picking_id.action_set_quantities_to_reservation()
|
||||
picking_id.button_validate()
|
||||
@@ -881,6 +881,42 @@ class StockPicking(models.Model):
|
||||
return name + str(num)
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
def create_tool_material_stock_moves(self, datas):
|
||||
picking_id = datas['picking_id']
|
||||
data = datas['data']
|
||||
stock_move_ids = []
|
||||
for res in data:
|
||||
if res:
|
||||
# 创建库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': picking_id.name,
|
||||
'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 write_tool_material_stock_move_lines(self, datas):
|
||||
picking_id = datas['picking_id']
|
||||
data = datas['data']
|
||||
move_line_ids = picking_id.move_line_ids
|
||||
for move_line_id in move_line_ids:
|
||||
for res in data:
|
||||
if move_line_id.lot_id.product_id == res['lot_id'].product_id:
|
||||
move_line_id.write({
|
||||
'current_location_id': res.get('current_location_id').id,
|
||||
'lot_id': res.get('lot_id').id
|
||||
})
|
||||
return True
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
@@ -915,38 +951,6 @@ class ProductProduct(models.Model):
|
||||
num = "%03d" % m
|
||||
return '%s-%s' % (code, num)
|
||||
|
||||
def create_tool_material_stock_moves(self, datas):
|
||||
picking_id = datas['picking_id']
|
||||
data = datas['data']
|
||||
stock_move_ids = []
|
||||
for res in data:
|
||||
if res:
|
||||
# 创建库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': picking_id.name,
|
||||
'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 write_tool_material_stock_move_lines(self, datas):
|
||||
picking_id = datas['picking_id']
|
||||
data = datas['data']
|
||||
move_line_ids = picking_id.move_line_ids
|
||||
for move_line_id in move_line_ids:
|
||||
for res in data:
|
||||
if move_line_id.lot_id.product_id == res['lot_id'].product_id:
|
||||
move_line_id.write({
|
||||
'current_location_id': res.get('current_location_id').id,
|
||||
'lot_id': res.get('lot_id').id
|
||||
})
|
||||
return True
|
||||
|
||||
|
||||
class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
|
||||
Reference in New Issue
Block a user