>>> db.define_table('itemx', Field('unit_price','double'), Field('quantity','integer'), >>> db.define_table('itemy', Field('unit_price','double'), Field('quantity','integer'),
>>> class MyVirtualFields(object): def __init__(self,table): self.table=table def total_price(self): record = getattr(self,self.table) return record.unit_price*record.quantity >>> db.itemx.virtualfields.append(MyVirtualFields('itemx')) >>> db.itemy.virtualfields.append(MyVirtualFields('itemy')) On Jun 2, 4:37 pm, Manuele Pesenti <manuele.pese...@gmail.com> wrote: > what if I want to define a virtual field and use it for different table > with same field names that I want to use in the virtual field > calculation? Do I have to cut & paste and chance only the table name in > the formula or there's a modular way to do it? > > thanks a lot > > Manuele