Does this work:

compute=lambda r: r['unit_price'] * 
db.quantity(r['quantity']).quantity_field

'quantity_field' would be the name of the field in db.quantity that stores 
the quantity you want to multiply.

Anthony

On Thursday, October 13, 2011 9:30:14 AM UTC-4, andrej burja wrote:
>
> what is the syntax of compute, if i use reference in the table definition
> db.define_table('item',
>         Field 
> <http://www.web2py.com/book/default/docstring/Field>('unit_price','double'),
>         Field 
> <http://www.web2py.com/book/default/docstring/Field>('quantity',db.quantity),
>         Field 
> <http://www.web2py.com/book/default/docstring/Field>('total_price',
>             compute=lambda r: r['unit_price']*r['?????']))
>
> entering'quantity' it uses id of that field
>
> andrej
>
>

Reply via email to