Skip to content

Commit

Permalink
Remove most uses of detached instances in stocklines module
Browse files Browse the repository at this point in the history
(The remaining use is in editing keyboard bindings; the linekeys module
also needs some work.)

Closes #294 on github.
  • Loading branch information
sde1000 committed Jul 10, 2024
1 parent a14e567 commit 50ce5f9
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 104 deletions.
1 change: 0 additions & 1 deletion quicktill/managetill.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def keypress(self, k):

def line_selected(self, kb):
self.dismiss()
td.s.add(kb)
if kb.stockline:
stocklines.modify(kb.stockline)
elif kb.plu:
Expand Down
9 changes: 3 additions & 6 deletions quicktill/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,24 +298,21 @@ def fits(s):


def print_restock_list(printer, rl):
"""
Print a list of (stockline,stockmovement) tuples.
"""Print a list of (stockline,stockmovement) tuples
A stockmovement tuple is (stockitem,fetchqty,newdisplayqty,qtyremain).
We can't assume that any of these objects are in the current
session.
All ORM objects must be attached to the current database session.
"""
with printer as d:
d.printline(f"\t{tillconfig.pubname}", emph=1)
d.printline("\tRe-stock list")
d.printline(f"\tPrinted {ui.formattime(now())}")
d.printline()
for sl, sm in rl:
td.s.add(sl)
d.printline(f"{sl.name}:")
d.printline(f"{sl.ondisplay}/{sl.capacity} displayed")
for item, move, newdisplayqty, stockqty_after_move in sm:
td.s.add(item)
if move > 0:
d.printline(f" {move} from item {item.id} "
f"leaving {stockqty_after_move}")
Expand Down
Loading

0 comments on commit 50ce5f9

Please sign in to comment.