update hatching

This commit is contained in:
2026-02-07 16:31:55 +03:30
parent b189e728e6
commit 583ed1b2c0

View File

@@ -806,9 +806,8 @@ class HatchingsViewSet(viewsets.ModelViewSet):
'MenuUserAccess', 'LogTableName', 'LogTableAlias', 'PageTitle', 'MenuUserAccess', 'LogTableName', 'LogTableAlias', 'PageTitle',
'PartIdCode', 'UnitTypeName' 'PartIdCode', 'UnitTypeName'
] ]
good_sum = request.data.get('GoodSum', {}) good_sums = request.data.get('GoodSum', {})
print(good_sum.get('loadingSum')) if int(good_sums.get('loadingSum',0)) > 0:
if int(good_sum.get('loadingSum',0)) > 0:
for key in same_keys: for key in same_keys:
if key in request.data and request.data[key] is not None: if key in request.data and request.data[key] is not None:
poultry_data[key] = request.data[key] poultry_data[key] = request.data[key]
@@ -865,6 +864,7 @@ class HatchingsViewSet(viewsets.ModelViewSet):
evacuation_details = request.data.get('EvacuationDetail', []) evacuation_details = request.data.get('EvacuationDetail', [])
if 'EvacuationDetail' in request.data: if 'EvacuationDetail' in request.data:
request.data.pop('EvacuationDetail') request.data.pop('EvacuationDetail')
if 'GoodSum' in request.data: if 'GoodSum' in request.data:
request.data.pop('GoodSum') request.data.pop('GoodSum')
@@ -875,15 +875,14 @@ class HatchingsViewSet(viewsets.ModelViewSet):
setattr(hatching, key, value) setattr(hatching, key, value)
if hatching.poultry is None: if hatching.poultry is None:
hatching.poultry=poultry hatching.poultry=poultry
good_sums = request.data.get('GoodSum', {}) # if isinstance(good_sums, dict):
if isinstance(good_sums, dict): hatching.GoodSum = good_sums.get('goodSum', 0)
hatching.GoodSum = good_sums.get('goodSum', 0) hatching.loadingSum = good_sums.get('loadingSum', 0)
hatching.loadingSum = good_sums.get('loadingSum', 0) # elif isinstance(good_sums, list) and len(good_sums) > 0:
elif isinstance(good_sums, list) and len(good_sums) > 0: # item = good_sums[0]
item = good_sums[0] # if isinstance(item, dict):
if isinstance(item, dict): # hatching.GoodSum = item.get('goodSum', 0)
hatching.GoodSum = item.get('goodSum', 0) # hatching.loadingSum = item.get('loadingSum', 0)
hatching.loadingSum = item.get('loadingSum', 0)
hatching.save() hatching.save()
hatching.save() hatching.save()
@@ -895,15 +894,14 @@ class HatchingsViewSet(viewsets.ModelViewSet):
request.data['Period'] = period request.data['Period'] = period
hatching = Hatching.objects.create(**request.data) hatching = Hatching.objects.create(**request.data)
hatching.ArchiveDate = hatching.Date + datetime.timedelta(days=76) hatching.ArchiveDate = hatching.Date + datetime.timedelta(days=76)
good_sums = request.data.get('GoodSum', {}) # if isinstance(good_sums, dict):
if isinstance(good_sums, dict): hatching.GoodSum = good_sums.get('goodSum', 0)
hatching.GoodSum = good_sums.get('goodSum', 0) hatching.loadingSum = good_sums.get('loadingSum', 0)
hatching.loadingSum = good_sums.get('loadingSum', 0) # elif isinstance(good_sums, list) and len(good_sums) > 0:
elif isinstance(good_sums, list) and len(good_sums) > 0: # item = good_sums[0]
item = good_sums[0] # if isinstance(item, dict):
if isinstance(item, dict): # hatching.GoodSum = item.get('goodSum', 0)
hatching.GoodSum = item.get('goodSum', 0) # hatching.loadingSum = item.get('loadingSum', 0)
hatching.loadingSum = item.get('loadingSum', 0)
if poultry: if poultry:
hatching.poultry = poultry hatching.poultry = poultry