I see two ways:

1) Using a left join

rows==db(db.Customer_storage.Customer_id==id_customer).select
(db.Customer_storage.ALL,db.Storage.Model,left=db.Storage.on
(db.Customer_storage.Object_id==db.Storage.id),orderby=db.Customer_storage.Object_id)

so now rows includes a Storage.Model column

2) In the view display db.Storage[row.Object_id].Model for each row in
rows

Denes.

On Jan 29, 9:23 am, ceriox <[email protected]> wrote:
> hi all,
> i don't know how to decode the field in one to many relation
>
> when i show "rows" i want to decode Customer_storage.Object_id whit
> Storage.Model for shwo to user a table like this:
> Object                  Serial number   Serial number sostituito        
> Garanzia
> Note
> ACME123            23s332
> 45d54                  2012/07/02         nothing
>
> thanks for help
>
> my db:
>
> db.define_table('Storage',
>     Field('Developer'),
>     Field('Model'),
>     Field('Version'),
>     Field('Colour'),
>     Field('Note', 'text'),
>     Field
> ('Data_creation','datetime',default=request.now,writable=False,readable=False))
>
> db.define_table('Customer_storage',
>     Field('Object_id',db.Storage, label='Dispositivo'),
>     Field('Customer_id',db.Customers,writable=False,readable=True),
>     Field('Sn', label='Serial number'),
>     Field('Sn_sostituito', label='Serial number se sostituito'),
>     Field('Garanzia', 'date', label='Data fine garanzia'),
>     Field('Note', 'text'),
>     Field
> ('Data_creation','datetime',default=request.now,writable=False,readable=False))
>
> my code:
> def materiale():
>     id_customer=request.args(0)
>     rows=db(db.Customer_storage.Customer_id==id_customer).select
> (orderby=db.Customer_storage.Object_id)
>     db.Customer_storage.Customer_id.default=id_customer
>     form=crud.create(db.Customer_storage, next=url
> ('materiale',id_customer))
>     return dict(form=form,rows=rows)

-- 
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.

Reply via email to