fix: update_buy perm_code=None 导致 NoneType 崩溃 + validateUnique 编辑时排除自身改用 Number() 防类型不一致

This commit is contained in:
yueli
2026-07-17 16:57:46 +08:00
parent a8fb0cfc94
commit 9bcd02c742
4 changed files with 12 additions and 15 deletions

View File

@ -214,10 +214,12 @@ def update_buy(id):
# 复制一份,避免遍历时修改字典
for field in list(data.keys()):
perm_code = field_to_perm.get(field)
if not perm_code:
continue # 不在映射中的字段跳过(不参与权限过滤)
# 提取不带前缀的基础权限码(如 'serial_number'
base_perm_code = perm_code.split(':')[-1] if ':' in perm_code else perm_code
# 如果用户的权限列表中,既没有长格式,也没有短格式,才移除该字段
if perm_code and perm_code not in user_permissions and base_perm_code not in user_permissions:
if perm_code not in user_permissions and base_perm_code not in user_permissions:
data.pop(field, None)
BuyInboundService.update_inbound(id, data)