Scratch that, I didn't realize that virtualfields had been added to Table. On Mar 17, 7:11 pm, "mr.freeze" <[email protected]> wrote: > I think you need to do: > > def sales(): > rows = db(db.sales.id>0).select() > rows = rows.setvirtualfields(sales=Sales()) > return dict(rows=rows) > > And remove this: > db.sales.virtualfields.append(Sales()) > > On Mar 17, 7:01 pm, Jose <[email protected]> wrote: > > > On 17 mar, 23:54, Jose <[email protected]> wrote: > > > > Fails, > > > > in model/db.py > > > > db.define_table('sales', > > > Field('item'), > > > Field('item_total', 'double'), > > > Field('tax_percentage', 'double'), > > > Field('trans_date', 'datetime'), > > > ) > > > > class Sales(): > > > def total(self): > > > return self.item_total * self.tax_percentage > > > def tax(self): > > > return self.total() - self.item_total > > > must be changed for this: > > > class Sales(): > > def total(self): > > return self.sales.item_total * self.sales.tax_percentage > > def tax(self): > > return self.total() - self.sales.item_total > >
-- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

