update KillHouseFreeBarInformationViewSet

This commit is contained in:
2026-02-10 16:20:43 +03:30
parent c9959c4032
commit 2372c412e9

View File

@@ -11771,6 +11771,8 @@ class KillHouseFreeBarInformationViewSet(viewsets.ModelViewSet):
def update(self, request, pk=None, *args, **kwargs):
user = SystemUserProfile.objects.get(user=request.user, trash=False)
free_bar = KillHouseFreeBarInformation.objects.get(key=request.data['key'])
pre_product = None
pre_kill_house = None
# product = free_bar.product
if 'live_weight' in request.data.keys():
@@ -11821,6 +11823,13 @@ class KillHouseFreeBarInformationViewSet(viewsets.ModelViewSet):
free_bar.acceptor_rejector = user.fullname
if 'killer_key' in request.data.keys() and request.data['killer_key'] != None and request.data[
'killer_key'] != '':
if free_bar.input_warehouse:
pre_kill_house = free_bar.input_warehouse
if (pre_kill_house.total_input_warehouse_free_weight - free_bar.weight_of_carcasses) - pre_kill_house.total_selling_warehouse_free_weight < 0 :
return Response(
{"result": "به علت عدم موجودی کشتارکن امکان جابجایی وجود ندارد! "},
status=status.HTTP_403_FORBIDDEN)
pre_product = RolesProducts.objects.filter(kill_house=pre_kill_house, trash=False, name='مرغ گرم').first()
exclusive_killer = KillHouse.objects.filter(trash=False, key=request.data['killer_key']).first()
if exclusive_killer.killer and exclusive_killer.type == 'public':
if not free_bar.public_killer:
@@ -11864,6 +11873,8 @@ class KillHouseFreeBarInformationViewSet(viewsets.ModelViewSet):
free_bar.other_share = int(other_share_percent * free_bar.total_wage_amount)
free_bar.save()
kill_house_free_buying_product_warehousing(free_bar.product)
if pre_product:
kill_house_free_buying_product_warehousing(pre_product)
return Response(serializer.data, status=status.HTTP_200_OK)
def destroy(self, request, pk=None, *args, **kwargs):