Compare commits
1 Commits
feature/67
...
release/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9719a2b5b |
@@ -791,48 +791,50 @@ class FunctionalToolAssembly(models.Model):
|
||||
# 刀柄之外的物料配置
|
||||
if options == '刀柄+整体式刀具':
|
||||
# 配置整体式刀具
|
||||
integra_lot_id = self._get_old_tool_material_lot(bom.get('integral_ids'))
|
||||
integra_location_lot_id = self._get_shelf_location_lot(integra_lot_id)
|
||||
integra_lot_ids = self._get_old_tool_material_lot(bom.get('integral_ids'))
|
||||
integra_location_lot_id = self._get_shelf_location_lot(integra_lot_ids)
|
||||
self.integral_freight_barcode_id = integra_location_lot_id.shelf_location_id.id
|
||||
self.integral_lot_id = integra_location_lot_id.lot_id.id
|
||||
else:
|
||||
# 配置刀片
|
||||
blade_lot_id = self._get_old_tool_material_lot(bom.get('blade_ids'))
|
||||
blade_location_lot_id = self._get_shelf_location_lot(blade_lot_id)
|
||||
blade_lot_ids = self._get_old_tool_material_lot(bom.get('blade_ids'))
|
||||
blade_location_lot_id = self._get_shelf_location_lot(blade_lot_ids)
|
||||
self.blade_freight_barcode_id = blade_location_lot_id.shelf_location_id.id
|
||||
self.blade_lot_id = blade_location_lot_id.lot_id.id
|
||||
|
||||
if options == '刀柄+刀杆+刀片':
|
||||
# 配置刀杆
|
||||
bar_lot_id = self._get_old_tool_material_lot(bom.get('bar_ids'))
|
||||
bar_location_lot_id = self._get_shelf_location_lot(bar_lot_id)
|
||||
bar_lot_ids = self._get_old_tool_material_lot(bom.get('bar_ids'))
|
||||
bar_location_lot_id = self._get_shelf_location_lot(bar_lot_ids)
|
||||
self.bar_freight_barcode_id = bar_location_lot_id.shelf_location_id.id
|
||||
self.bar_lot_id = bar_location_lot_id.lot_id.id
|
||||
elif options == '刀柄+刀盘+刀片':
|
||||
# 配置刀盘
|
||||
pad_lot_id = self._get_old_tool_material_lot(bom.get('pad_ids'))
|
||||
pad_location_lot_id = self._get_shelf_location_lot(pad_lot_id)
|
||||
pad_lot_ids = self._get_old_tool_material_lot(bom.get('pad_ids'))
|
||||
pad_location_lot_id = self._get_shelf_location_lot(pad_lot_ids)
|
||||
self.pad_freight_barcode_id = pad_location_lot_id.shelf_location_id.id
|
||||
self.pad_lot_id = pad_location_lot_id.lot_id.id
|
||||
|
||||
def _get_old_tool_material_lot(self, material_ids):
|
||||
""" 根据先进先出原则选择物料批次 """
|
||||
location_id = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
stock_quant = self.env['stock.quant'].sudo().search(
|
||||
stock_quant_ids = self.env['stock.quant'].sudo().search(
|
||||
[('location_id', '=', location_id.id), ('product_id', 'in', material_ids.ids), ('quantity', '>', '0')],
|
||||
order='lot_id', limit=1)
|
||||
if stock_quant:
|
||||
return stock_quant.lot_id
|
||||
order='lot_id')
|
||||
if stock_quant_ids:
|
||||
return [stock_quant_id.lot_id for stock_quant_id in stock_quant_ids]
|
||||
else:
|
||||
raise ValidationError(f'【{material_ids[0].cutting_tool_material_id.name}】物料库存不足,请先进行盘点或采购')
|
||||
|
||||
def _get_shelf_location_lot(self, lot_id):
|
||||
def _get_shelf_location_lot(self, lot_ids):
|
||||
"""根据所给的刀具物料批次号,返回一个刀具物料货位、批次信息"""
|
||||
location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)])
|
||||
if not location_lots:
|
||||
raise ValidationError(f'没有查询到批次为【{lot_id.name}】物料的货位信息!')
|
||||
else:
|
||||
return location_lots[0]
|
||||
for lot_id in lot_ids:
|
||||
location_lots = self.env['sf.shelf.location.lot'].sudo().search([('lot_id', '=', lot_id.id)])
|
||||
if location_lots:
|
||||
return location_lots[0]
|
||||
if lot_ids:
|
||||
raise ValidationError(
|
||||
f'【{lot_ids[0].product_id.cutting_tool_material_id.name}】物料在货位上库存不足,请先进行盘点或采购!')
|
||||
|
||||
def _get_inventory_bom(self, inventory_id):
|
||||
"""获取BOM的刀具物料产品信息"""
|
||||
|
||||
Reference in New Issue
Block a user