fix: require store for new orders, if so configured
This commit is contained in:
parent
f3cca2e370
commit
7ea83b2715
|
@ -1017,8 +1017,14 @@ class NewOrderBatchHandler(BatchHandler):
|
|||
def why_not_execute(self, batch, **kwargs):
|
||||
"""
|
||||
By default this checks to ensure the batch has a customer with
|
||||
phone number, and at least one item.
|
||||
phone number, and at least one item. It also may check to
|
||||
ensure the store is assigned, if applicable.
|
||||
"""
|
||||
if not batch.store_id:
|
||||
order_handler = self.app.get_order_handler()
|
||||
if order_handler.expose_store_id():
|
||||
return "Must assign the store"
|
||||
|
||||
if not batch.customer_name:
|
||||
return "Must assign the customer"
|
||||
|
||||
|
|
|
@ -1114,9 +1114,15 @@ class TestNewOrderBatchHandler(DataTestCase):
|
|||
self.session.add(row)
|
||||
self.session.flush()
|
||||
|
||||
# batch is okay to execute..
|
||||
reason = handler.why_not_execute(batch)
|
||||
self.assertIsNone(reason)
|
||||
|
||||
# unless we also require store
|
||||
self.config.setdefault('sideshow.orders.expose_store_id', 'true')
|
||||
reason = handler.why_not_execute(batch)
|
||||
self.assertEqual(reason, "Must assign the store")
|
||||
|
||||
def test_make_local_customer(self):
|
||||
model = self.app.model
|
||||
enum = self.app.enum
|
||||
|
|
Loading…
Reference in a new issue