fix: prevent inbound of disabled materials
This commit is contained in:
@ -60,7 +60,9 @@ class BuyInboundService:
|
||||
@staticmethod
|
||||
def search_base_material(keyword):
|
||||
try:
|
||||
# [核心修改] 只查询已启用的物料,防止选择已禁用的历史物料
|
||||
query = MaterialBase.query.filter(MaterialBase.is_enabled == True)
|
||||
|
||||
if keyword:
|
||||
query = query.filter(
|
||||
or_(
|
||||
@ -100,6 +102,10 @@ class BuyInboundService:
|
||||
if not material:
|
||||
raise ValueError("所选物料不存在")
|
||||
|
||||
# [核心修改] 后端二次校验:如果物料已停用,禁止入库
|
||||
if not material.is_enabled:
|
||||
raise ValueError(f"物料【{material.name}】已停用,无法办理新入库。")
|
||||
|
||||
# --- [修复点] 执行唯一性校验 ---
|
||||
BuyInboundService._check_unique(
|
||||
base_id=base_id,
|
||||
|
||||
Reference in New Issue
Block a user