If you are in 'edit' mode in your SQLFORM.grid, set the default value for 
that field equal to the value for your order.

if request.args(0) == 'edit':
   db.order_items.order_id.default = request.args(2)

Place this BEFORE your grid = SQLFORM.grid(...)

-- not tested --

-Jim

On Wednesday, March 13, 2013 4:52:34 PM UTC-5, Jeison Dück wrote:
>
> Hello, all,
>
> I have those 3 models bellow:
>
> db.define_table('order',
>    db.Field('customer', db.customer),
>    db.Field('autor', db.auth_user),
>    db.Field('created', 'datetime'),
> )
>
> db.define_table('product',
>    db.Field('name'),
>    db.Field('value'),
>    format='%(name)s'
>    )
>
> db.define_table('order_items',
>    db.Field('order_id', db.order, required=True),
>    db.Field('product_id', db.product, required=True),
>    db.Field('amount', 'integer', required=True, default=1),
>    db.Field('value','decimal(20,2)', required=True, default=0),
>    db.Field('total', compute=lambda r: (float(r['preco'] * r['quantidade'])
>    )
>
>
> They are displayed as form for order record and bellow a SQLFORM.grid for 
> displaying order_items.
> Is there a way for setting default value for order_items.value to be the 
> same as product.value, from parent table?
>
> Also, is it possible to add a row for totals for a column?
>
>
> Thanks for any suggestion
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to