fix: resolve MaterialBase sku property error and add dynamic refresh after stock adjustment

This commit is contained in:
DXC
2026-03-18 14:01:36 +08:00
parent 33969b8336
commit ac15ef74db
2 changed files with 12 additions and 6 deletions

View File

@ -561,10 +561,15 @@ def export_stocktake():
# 安全获取 sku
stock_sku = getattr(stock, 'sku', None) or getattr(stock, 'SKU', None) or '-'
# 尝试从MaterialBase获取名称
# 使用 base_id 或 material_id 关联查询物料基础表(安全方式)
material = None
if stock_sku and stock_sku != '-':
material = MaterialBase.query.filter_by(sku=stock_sku).first()
base_id = getattr(stock, 'base_id', None) or getattr(stock, 'material_id', None)
if base_id:
material = MaterialBase.query.get(base_id)
else:
# 如果没有 base_id尝试用 code 兜底查询
if hasattr(MaterialBase, 'code') and stock_sku != '-':
material = MaterialBase.query.filter_by(code=stock_sku).first()
return {
'name': material.name if material else stock_sku,

View File

@ -910,7 +910,8 @@ const handleAdjust = async (row: any) => {
ElMessage.success(res.message || '调整成功')
// 刷新差异列表
// 刷新数据并重新打开差异列表
await loadData()
await openVarianceDialog()
} catch (e: any) {
if (e !== 'cancel') ElMessage.error(e?.message || '操作失败')