forked from erp-dev/erp
fix: frozen excluded from stock api
This commit is contained in:
@@ -8,6 +8,7 @@ from typing import Any, Dict, Iterable, List, Tuple, Optional
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
|
||||
from basic_info import models as basic_info_models
|
||||
from stock import models as stock_models
|
||||
@@ -1273,6 +1274,28 @@ def _approve_sales_order(
|
||||
source_id=locked_order.id,
|
||||
)
|
||||
|
||||
consume_detail_ids: List[int] = []
|
||||
for item in locked_order.items.all():
|
||||
raw_ids = (item.consume_detail_ids or '').strip()
|
||||
if not raw_ids:
|
||||
continue
|
||||
consume_detail_ids.extend(
|
||||
int(value)
|
||||
for value in raw_ids.split(',')
|
||||
if value.strip()
|
||||
)
|
||||
if consume_detail_ids:
|
||||
stock_models.StockFreeze.objects.filter(
|
||||
merchant=locked_order.merchant,
|
||||
stock_detail_id__in=consume_detail_ids,
|
||||
status=stock_models.StockFreezeStatusEnum.FROZEN,
|
||||
).update(
|
||||
status=stock_models.StockFreezeStatusEnum.COMPLETED,
|
||||
completed_by=reviewed_by,
|
||||
completed_at=timezone.now(),
|
||||
completed_with=locked_order.id,
|
||||
)
|
||||
|
||||
created_by_id = getattr(reviewed_by, 'id', None)
|
||||
if _auto_stock_task_enabled(locked_order.merchant):
|
||||
logger.info('审批通过销售单 %s,触发出库任务', locked_order.id)
|
||||
|
||||
Reference in New Issue
Block a user