Fix: Show voucher without kots and iventories would cause an error in show.

This commit is contained in:
2025-08-04 14:54:42 +00:00
parent 3e8f2e9736
commit b33468a43f

View File

@ -212,8 +212,19 @@ def from_table(
)
)
.unique()
.scalar_one()
.scalar_one_or_none()
)
if item is None:
item = db.execute(
select(Voucher)
.join(Voucher.food_table)
.join(Voucher.customer, isouter=True)
.where(Voucher.id == v)
.options(
contains_eager(Voucher.food_table),
contains_eager(Voucher.customer),
)
).scalar_one()
if guest is not None:
item.customer = guest.customer