pack get bug

This commit is contained in:
caoqianming 2022-02-23 09:11:18 +08:00
parent a13f1cc950
commit cf78837fb2
1 changed files with 7 additions and 1 deletions

View File

@ -160,6 +160,12 @@ class SaleProductViewSet(ListModelMixin, DestroyModelMixin, CreateModelMixin, Ge
sale.save()
return Response()
def create(self, request, *args, **kwargs):
obj = self.get_object()
sale = obj.sale
if sale.is_audited:
raise exceptions.APIException('该销售记录已审核,不可添加产品')
return super().create(request, *args, **kwargs)
@action(methods=['get', 'post'], detail=True, perms_map={'post':'sale_pack'}, serializer_class=SaleProductPackSerializer)
@transaction.atomic
@ -169,7 +175,7 @@ class SaleProductViewSet(ListModelMixin, DestroyModelMixin, CreateModelMixin, Ge
"""
obj = self.get_object()
if request.method == 'GET':
for i in PackItem.objects.filter(product=obj.product.material, is_deleted=False):
for i in PackItem.objects.filter(product=obj.iproduct.material, is_deleted=False):
SalePack.objects.get_or_create(sale_product=obj, packitem=i,
defaults={
"sale_product":obj,