We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e535570 commit da05078Copy full SHA for da05078
src/allocation/views.py
@@ -3,14 +3,10 @@
3
4
def allocations(orderid: str, uow: unit_of_work.SqlAlchemyUnitOfWork):
5
with uow:
6
- results = uow.session.execute(
7
- """
8
- SELECT ol.sku, b.reference
9
- FROM allocations AS a
10
- JOIN batches AS b ON a.batch_id = b.id
11
- JOIN order_lines AS ol ON a.orderline_id = ol.id
12
- WHERE ol.orderid = :orderid
13
- """,
14
- dict(orderid=orderid),
15
- )
16
- return [{"sku": sku, "batchref": batchref} for sku, batchref in results]
+ products = uow.products.for_order(orderid=orderid)
+ batches = [b for p in products for b in p.batches]
+ return [
+ {"sku": b.sku, "batchref": b.reference}
+ for b in batches
+ if orderid in b.orderids
+ ]
0 commit comments