Accept Merge Request #1997: (feature/功能刀具组装初始化优化 -> develop)

Merge Request: 功能刀具组装自动根据BOM配置初始物料信息优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1997
This commit is contained in:
禹翔辉
2025-04-14 10:34:47 +08:00
committed by Coding

View File

@@ -782,10 +782,11 @@ class FunctionalToolAssembly(models.Model):
"""根据BOM对刀具物料进行初始配置"""
options = bom.get('options')
# 配置刀柄信息
for handle_id in bom.get('handle_ids'):
handle_ids = self._get_old_tool_material_lot(bom.get('handle_ids'))
for handle_id in handle_ids:
if handle_id:
if not self.handle_product_id:
self.handle_product_id = handle_id.id
self.handle_product_id = handle_id.product_id.id
break
# 刀柄之外的物料配置
@@ -820,19 +821,20 @@ class FunctionalToolAssembly(models.Model):
location_id = self.env['stock.location'].search([('name', '=', '刀具房')])
stock_quant = self.env['stock.quant'].sudo().search(
[('location_id', '=', location_id.id), ('product_id', 'in', material_ids.ids), ('quantity', '>', '0')],
order='lot_id', limit=1)
order='lot_id')
if stock_quant:
return stock_quant.lot_id
return [quant.lot_id for quant in stock_quant]
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]
raise ValidationError(f'{lot_ids[0].product_id.cutting_tool_material_id.name}】物料在货位库存不足,请先进行盘点入库')
def _get_inventory_bom(self, inventory_id):
"""获取BOM的刀具物料产品信息"""