feat: added new fields

This commit is contained in:
Pablo Moreno
2024-05-19 21:53:52 +02:00
parent 26c2fded92
commit 91bf18de6d
4 changed files with 174 additions and 21 deletions
+4 -1
View File
@@ -90,7 +90,9 @@ class ProductPriceViewSet(ModelViewSet):
return self.serializer_class
def perform_create(self, serializer):
serializer.save(product_id=self.kwargs.get("product_id"))
product = get_object_or_404(Product, pk=self.kwargs.get("product_id"))
product.prices.all().update(current=False)
serializer.save(product=product, current=True)
class ProductBatchViewSet(ModelViewSet):
@@ -115,6 +117,7 @@ class TaxViewSet(ModelViewSet):
serializer_class = TaxSerializer
queryset = Tax.objects.all()
permission_classes = (IsAdminUser,)
search_fields = ('code', )
class OrderViewSet(ModelViewSet):