Исправил закрытие сделки. добавил черновик страницы для списания в 1С
All checks were successful
Deploy MES Core / deploy (push) Successful in 13s
All checks were successful
Deploy MES Core / deploy (push) Successful in 13s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
|
||||
from manufacturing.models import ProductEntity
|
||||
|
||||
@@ -76,7 +77,9 @@ def close_cutting_session(session_id: int) -> None:
|
||||
|
||||
si.quantity = float(si.quantity) - need
|
||||
if si.quantity == 0:
|
||||
si.delete()
|
||||
si.is_archived = True
|
||||
si.archived_at = timezone.now()
|
||||
si.save(update_fields=['quantity', 'is_archived', 'archived_at'])
|
||||
else:
|
||||
si.save(update_fields=['quantity'])
|
||||
|
||||
@@ -126,7 +129,9 @@ def close_cutting_session(session_id: int) -> None:
|
||||
raise RuntimeError('Недостаточно сырья для списания.')
|
||||
|
||||
if used.quantity == 0:
|
||||
used.delete()
|
||||
used.is_archived = True
|
||||
used.archived_at = timezone.now()
|
||||
used.save(update_fields=['quantity', 'is_archived', 'archived_at'])
|
||||
else:
|
||||
used.save(update_fields=['quantity'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user