1. Joel Mohler
  2. PyHacc

Commits

Joel Mohler  committed 8eef606

make DockCommands report selection explicit and therefore more robust

  • Participants
  • Parent commits 77088df
  • Branches default

Comments (0)

Files changed (2)

File pyhacc/BalanceDock.py

View file
  • Ignore whitespace
     def __init__(self, Session, parent):
         self.Session = Session
         self.parent = parent
+        self.ReportClass = None
 
     commands = CommandMenu("_commands")
 
     @commands.itemAction("&Print", iconFile=":/pyhacc/document-print.ico", requireSelection=False, viewRelated=False)
     def cmd_print(self, id=None):
-        if isinstance(self.parent, BalanceSheetAccountBalances):
-            from pyhacc.reports import BalanceSheet as rpt
-        else:
-            from pyhacc.reports import ProfitAndLoss as rpt
-        bs = rpt(self.Session)
+        if self.ReportClass is None:
+            raise RuntimeError("DockCommands report class is not initialized.")
+
+        bs = self.ReportClass(self.Session)
         bs.construct()
         import tempfile
         import os
     def __init__(self, parent, Session):
         super(BalanceSheetAccountBalances, self).__init__(parent, Session)
 
+        import pyhacc.reports as reports
+        self.entity2.ReportClass = reports.BalanceSheet
+
         self.setWindowTitle("Balances")
         self.setObjectName("BalanceDock")
 
     def __init__(self, parent, Session):
         super(ProfitAndLossAccountBalances, self).__init__(parent, Session)
 
+        import pyhacc.reports as reports
+        self.entity2.ReportClass = reports.ProfitAndLoss
+
         self.setWindowTitle("Profit && Loss")
         self.setObjectName("PandLAccounts")
 

File pyhacc/transactions.py

View file
  • Ignore whitespace
     win.tranBindings.refresh.connect(load)
     win.addToolBar(win.toolbar)
 
+    import pyhacc.reports as reports
+    win.entity.ReportClass = reports.TransactionList
+
     def contextMenu(pos, tran):
         c.thingMenu = QtGui.QMenu(c)
         c.thingBinding = c.entity.itemCommands.withObject(tran, objectConverter=lambda x:x.tid)