From 76446d801fad25f5553a1ffbe62cd87ef7501fa2 Mon Sep 17 00:00:00 2001 From: Lance Edgar <lance@edbob.org> Date: Tue, 12 Nov 2019 11:53:03 -0600 Subject: [PATCH] Try to assign configured store when making new purchase batch so the UI logic doesn't need to do anything special for that --- rattail/batch/purchase.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rattail/batch/purchase.py b/rattail/batch/purchase.py index 2ca2edc3..b255d1a7 100644 --- a/rattail/batch/purchase.py +++ b/rattail/batch/purchase.py @@ -63,6 +63,22 @@ class PurchaseBatchHandler(BatchHandler): return self.config.getbool('rattail.batch', 'purchase.allow_expired_credits', default=True) + def make_basic_batch(self, session, **kwargs): + """ + Create a "bare minimum" batch object. + + Here we'll set the default store, if none is provided. + """ + # try to assign store for new batch + if 'store_uuid' not in kwargs and 'store' not in kwargs: + store = self.config.get_store(session) + if store: + kwargs['store'] = store + + # continue with usual logic + batch = super(PurchaseBatchHandler, self).make_basic_batch(session, **kwargs) + return batch + def should_populate(self, batch): # TODO: this probably should change soon, for now this works.. return batch.purchase and batch.mode in (self.enum.PURCHASE_BATCH_MODE_RECEIVING,