sale_product接口
This commit is contained in:
parent
87369611bb
commit
ac4063d97e
|
|
@ -1,5 +1,5 @@
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework import serializers
|
from rest_framework import exceptions, serializers
|
||||||
|
|
||||||
from apps.inm.models import IProduct
|
from apps.inm.models import IProduct
|
||||||
from apps.inm.serializers import IProductListSerializer
|
from apps.inm.serializers import IProductListSerializer
|
||||||
|
|
@ -71,6 +71,9 @@ class SaleCreateSerializer(serializers.ModelSerializer):
|
||||||
if order.customer:
|
if order.customer:
|
||||||
attrs['customer'] = order.customer
|
attrs['customer'] = order.customer
|
||||||
attrs['product'] = order.product
|
attrs['product'] = order.product
|
||||||
|
for i in attrs['iproducts']:
|
||||||
|
if i.material is not attrs['product']:
|
||||||
|
raise exceptions.APIException('产品选取错误')
|
||||||
return super().validate(attrs)
|
return super().validate(attrs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db.models import base
|
from django.db.models import base
|
||||||
from rest_framework import urlpatterns
|
from rest_framework import urlpatterns
|
||||||
from apps.sam.views import CustomerViewSet,ContractViewSet,OrderViewSet, SaleViewSet
|
from apps.sam.views import CustomerViewSet,ContractViewSet,OrderViewSet, SaleProductViewSet, SaleViewSet
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
|
@ -9,6 +9,7 @@ router.register('customer', CustomerViewSet, basename='customer')
|
||||||
router.register('contract', ContractViewSet, basename='contract')
|
router.register('contract', ContractViewSet, basename='contract')
|
||||||
router.register('order', OrderViewSet, basename='order')
|
router.register('order', OrderViewSet, basename='order')
|
||||||
router.register('sale', SaleViewSet, basename='sale')
|
router.register('sale', SaleViewSet, basename='sale')
|
||||||
|
router.register('sale_product', SaleProductViewSet, basename='sale_product')
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', include(router.urls)),
|
path('', include(router.urls)),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue