diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 56e9679a..99a243ef 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -405,10 +405,10 @@ class ProductsView(MasterView): if batch_key and batch_key in supported: handler = get_batch_handler(self.rattail_config, batch_key, default=supported[batch_key]) - + products = self.get_effective_data() progress = SessionProgress(self.request, 'products.batch') thread = Thread(target=self.make_batch_thread, - args=(handler, self.request.user.uuid, progress)) + args=(handler, self.request.user.uuid, products, progress)) thread.start() return self.render_progress({ 'key': 'products.batch', @@ -423,16 +423,15 @@ class ProductsView(MasterView): return {'supported_batches': batch_types} - def make_batch_thread(self, handler, user_uuid, progress): + def make_batch_thread(self, handler, user_uuid, products, progress): """ Threat target for making a batch from current products query. """ session = RattailSession() user = session.query(model.User).get(user_uuid) assert user - products = self.get_effective_query(session) batch = handler.make_batch(session, created_by=user) - batch.products = products.all() + batch.products = products.with_session(session).all() handler.make_initial_rows(batch, progress=progress) session.commit()