fix: 出库/借库扫码查库存与 BOM 子件物料选择加行级公司隔离(超管/跨域不受限)
This commit is contained in:
@ -357,6 +357,12 @@ def get_material_base_list():
|
|||||||
# 构建查询条件
|
# 构建查询条件
|
||||||
query = MaterialBase.query.filter_by(is_enabled=True)
|
query = MaterialBase.query.filter_by(is_enabled=True)
|
||||||
|
|
||||||
|
# ★ 行级公司隔离:普通用户只能选本公司的物料作为 BOM 子件(超管/跨域不受限)
|
||||||
|
from app.utils.decorators import get_current_company_filter
|
||||||
|
company_limit = get_current_company_filter()
|
||||||
|
if company_limit is not None:
|
||||||
|
query = query.filter(MaterialBase.company_name == company_limit)
|
||||||
|
|
||||||
# 添加关键字模糊搜索
|
# 添加关键字模糊搜索
|
||||||
if keyword:
|
if keyword:
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
|
|||||||
@ -58,25 +58,42 @@ class OutboundService:
|
|||||||
return float(item.pre_tax_unit_price) if item.pre_tax_unit_price else 0
|
return float(item.pre_tax_unit_price) if item.pre_tax_unit_price else 0
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
prod = StockProduct.query.filter(
|
# ★ 行级公司隔离:扫码出库/借库只能命中本公司的库存(超管/跨域不受限)
|
||||||
|
from app.utils.decorators import get_current_company_filter
|
||||||
|
from app.models.base import MaterialBase
|
||||||
|
company_limit = get_current_company_filter()
|
||||||
|
|
||||||
|
prod_q = StockProduct.query.filter(
|
||||||
or_(StockProduct.barcode == clean_code, StockProduct.sku == clean_code)
|
or_(StockProduct.barcode == clean_code, StockProduct.sku == clean_code)
|
||||||
).first()
|
)
|
||||||
|
if company_limit is not None:
|
||||||
|
prod_q = prod_q.join(MaterialBase, StockProduct.base_id == MaterialBase.id) \
|
||||||
|
.filter(MaterialBase.company_name == company_limit)
|
||||||
|
prod = prod_q.first()
|
||||||
if prod:
|
if prod:
|
||||||
res = OutboundService._format_scan_result(prod, 'stock_product')
|
res = OutboundService._format_scan_result(prod, 'stock_product')
|
||||||
res['price'] = get_price(prod, 'stock_product')
|
res['price'] = get_price(prod, 'stock_product')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
semi = StockSemi.query.filter(
|
semi_q = StockSemi.query.filter(
|
||||||
or_(StockSemi.barcode == clean_code, StockSemi.sku == clean_code)
|
or_(StockSemi.barcode == clean_code, StockSemi.sku == clean_code)
|
||||||
).first()
|
)
|
||||||
|
if company_limit is not None:
|
||||||
|
semi_q = semi_q.join(MaterialBase, StockSemi.base_id == MaterialBase.id) \
|
||||||
|
.filter(MaterialBase.company_name == company_limit)
|
||||||
|
semi = semi_q.first()
|
||||||
if semi:
|
if semi:
|
||||||
res = OutboundService._format_scan_result(semi, 'stock_semi')
|
res = OutboundService._format_scan_result(semi, 'stock_semi')
|
||||||
res['price'] = 0
|
res['price'] = 0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
buy = StockBuy.query.filter(
|
buy_q = StockBuy.query.filter(
|
||||||
or_(StockBuy.barcode == clean_code, StockBuy.sku == clean_code)
|
or_(StockBuy.barcode == clean_code, StockBuy.sku == clean_code)
|
||||||
).first()
|
)
|
||||||
|
if company_limit is not None:
|
||||||
|
buy_q = buy_q.join(MaterialBase, StockBuy.base_id == MaterialBase.id) \
|
||||||
|
.filter(MaterialBase.company_name == company_limit)
|
||||||
|
buy = buy_q.first()
|
||||||
if buy:
|
if buy:
|
||||||
res = OutboundService._format_scan_result(buy, 'stock_buy')
|
res = OutboundService._format_scan_result(buy, 'stock_buy')
|
||||||
res['price'] = get_price(buy, 'stock_buy')
|
res['price'] = get_price(buy, 'stock_buy')
|
||||||
|
|||||||
Reference in New Issue
Block a user