johnf wrote: > I have classic grid that contains a list of payments made on account. The > grid is populated from the bizobj payments which is a child of the client. > > I need the subtotal and the balance. Total amt - subtotal = balance > > The bizobj has > addField('amt_rec') > addField('fk_client') > > I now have to sum(amt_rec) where fk_client = somePkOfClient. > > VirtualFields = {"subtotal": self.getSubTotal} > > def getSubTotal(self): > tempCur=self.getTempCursor() > tempCur.execute("Select sum(amt_rec) as totalrec from payments where > fk_client = %s" % client_pkid) > return tempCur.Record.totalrec > > "subtotal" has the correct figure. > > Can I use "subtotal" in the next virtual field? > > def getBalance(self): > return total - self.subtotal
Yes, you can use the results of virtual fields in other virtual fields. You may just call getSubTotal() directly though. > What is the correct way to handle this? Be aware that the virtual fields will calc every time the grid asks for a refresh. Paul _______________________________________________ Post Messages to: Dabo-users@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/4a1414e0.6000...@ulmcnett.com