fix: require vendor when making new ordering batch via api
pretty sure this pattern needs to be expanded and probably improved, but wanted to fix this one scenario for now, per error email
This commit is contained in:
parent
ec5ed490d9
commit
9b6447c4cb
|
@ -86,6 +86,8 @@ class OrderingBatchViews(APIBatchView):
|
||||||
Sets the mode to "ordering" for the new batch.
|
Sets the mode to "ordering" for the new batch.
|
||||||
"""
|
"""
|
||||||
data = dict(data)
|
data = dict(data)
|
||||||
|
if not data.get('vendor_uuid'):
|
||||||
|
raise ValueError("You must specify the vendor")
|
||||||
data['mode'] = self.enum.PURCHASE_BATCH_MODE_ORDERING
|
data['mode'] = self.enum.PURCHASE_BATCH_MODE_ORDERING
|
||||||
batch = super().create_object(data)
|
batch = super().create_object(data)
|
||||||
return batch
|
return batch
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2023 Lance Edgar
|
# Copyright © 2010-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -31,7 +31,7 @@ from rattail.db.util import get_fieldnames
|
||||||
|
|
||||||
from cornice import resource, Service
|
from cornice import resource, Service
|
||||||
|
|
||||||
from tailbone.api import APIView, api
|
from tailbone.api import APIView
|
||||||
from tailbone.db import Session
|
from tailbone.db import Session
|
||||||
from tailbone.util import SortColumn
|
from tailbone.util import SortColumn
|
||||||
|
|
||||||
|
@ -355,7 +355,11 @@ class APIMasterView(APIView):
|
||||||
data = self.request.json_body
|
data = self.request.json_body
|
||||||
|
|
||||||
# add instance to session, and return data for it
|
# add instance to session, and return data for it
|
||||||
|
try:
|
||||||
obj = self.create_object(data)
|
obj = self.create_object(data)
|
||||||
|
except Exception as error:
|
||||||
|
return self.json_response({'error': str(error)})
|
||||||
|
else:
|
||||||
self.Session.flush()
|
self.Session.flush()
|
||||||
return self._get(obj)
|
return self._get(obj)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue