update hatching
This commit is contained in:
@@ -858,11 +858,14 @@ class HatchingsViewSet(viewsets.ModelViewSet):
|
||||
|
||||
poultry = Poultry.objects.filter(SystemCode=system_code).first()
|
||||
bars = request.data.get('Transports', [])
|
||||
good_sums = request.data.get('GoodSum', [])
|
||||
if 'Transports' in request.data:
|
||||
request.data.pop('Transports')
|
||||
evacuation_details = request.data.get('EvacuationDetail', [])
|
||||
if 'EvacuationDetail' in request.data:
|
||||
request.data.pop('EvacuationDetail')
|
||||
if 'GoodSum' in request.data:
|
||||
request.data.pop('GoodSum')
|
||||
|
||||
hatching = Hatching.objects.filter(RequestCode=request.data['RequestCode']).first()
|
||||
print({'1': request.data['ProvinceName']})
|
||||
@@ -871,6 +874,8 @@ class HatchingsViewSet(viewsets.ModelViewSet):
|
||||
setattr(hatching, key, value)
|
||||
if hatching.poultry is None:
|
||||
hatching.poultry=poultry
|
||||
hatching.GoodSum = good_sums['goodSum']
|
||||
hatching.loadingSum = good_sums['loadingSum']
|
||||
hatching.save()
|
||||
|
||||
else:
|
||||
@@ -880,6 +885,8 @@ class HatchingsViewSet(viewsets.ModelViewSet):
|
||||
request.data['Period'] = period
|
||||
hatching = Hatching.objects.create(**request.data)
|
||||
hatching.ArchiveDate = hatching.Date + datetime.timedelta(days=76)
|
||||
hatching.GoodSum = good_sums['goodSum']
|
||||
hatching.loadingSum = good_sums['loadingSum']
|
||||
|
||||
if poultry:
|
||||
hatching.poultry = poultry
|
||||
|
||||
Reference in New Issue
Block a user