fix: prevent inbound of disabled materials
This commit is contained in:
@ -54,7 +54,7 @@ class SemiInboundService:
|
||||
@staticmethod
|
||||
def search_base_material(keyword):
|
||||
try:
|
||||
# 基础查询:必须是已启用的物料
|
||||
# [核心修改] 只查询已启用的物料
|
||||
query = MaterialBase.query.filter(MaterialBase.is_enabled == True)
|
||||
|
||||
# 如果有关键词,进行模糊匹配
|
||||
@ -101,6 +101,10 @@ class SemiInboundService:
|
||||
if not material:
|
||||
raise ValueError(f"ID为 {base_id} 的基础物料不存在")
|
||||
|
||||
# [核心修改] 后端二次校验:如果物料已停用,禁止入库
|
||||
if not material.is_enabled:
|
||||
raise ValueError(f"物料【{material.name}】已停用,无法办理新入库。")
|
||||
|
||||
# --- [核心修改] 执行唯一性校验 ---
|
||||
SemiInboundService._check_unique(
|
||||
base_id=base_id,
|
||||
|
||||
Reference in New Issue
Block a user