*Pedido.*ordem_servico_id*.requires = IS_IN_DB(Ordem_Servico),
'ordem_servico.id <http://ordem_servico.id/>',*
*                                            lambda r: '%s - os: %s' %
(r.ordem_servico_id.produto_id.cliente_id.nome_cliente,*
                              *
     r.ordem_servico_id.identificador_os))*

2018-06-27 12:25 GMT-03:00 Diego Tostes <dtos...@gmail.com>:

> Hi Anthony,
>
>
> i think that put the requires make my code more organized ... But it is a
> personal choice. I did changes in my tables and now i have:
>
>
> Clientes = db.define_table('clientes',
>     Field('cnpj', 'string', label=T("CNPJ")),
>     Field('nome_cliente', 'string', label=T("Cliente")),
>     Field('email', 'string', label=T("E-mail")),
>     Field('telefone', 'string', label=T("Telefone")),
>     Field('responsavel_contato', 'string', label=T("Responsável")),
> )
>
> Produto = db.define_table('produto',
>     Field('ficha_tecnica', 'upload', label=T("Ficha Tecnica")),
>     Field('descricao_produto', 'string', label=T("Descricao Produto")),
>     Field('cliente_id', db.clientes, label=T("Cliente ID")),
> )
>
> Ordem_Servico = db.define_table('ordem_servico',
>     Field('identificador_os', 'string'),
>     Field('produto_id', db.produto),
>     Field('finalizado', "boolean"),
>     )
>
> Pedido = db.define_table('pedido',
>     Field('ordem_servico_id', db.ordem_servico),
>     Field('tipo_pedido', "integer", label=T("tp"))
>
>
> *Pedido.produto_id.requires = IS_IN_DB(Ordem_Servico), 'ordem_servico.id
> <http://ordem_servico.id>',*
> *                                            lambda r: '%s - os: %s' %
> (r.ordem_servico_id.produto_id.cliente_id.nome_cliente,*
> *
>      r.ordem_servico_id.identificador_os))*
>
> ----> is it possible to "navigate" like this?
>
> *r.ordem_servico_id.produto_id.cliente_id.nome_cliente*
>
> *to get the "nome_cliente" ?*
>
> Rgds
>
>
> Diego
>
> 2018-06-20 12:05 GMT-03:00 Diego Tostes <dtos...@gmail.com>:
>
>> Thanks Antony.
>>
>> I will code again with your tips.
>>
>> Rgds
>>
>> Diego
>>
>> 2018-06-20 11:56 GMT-03:00 Anthony <abasta...@gmail.com>:
>>
>>> Materia_Prima.pedido_id.requires = IS_IN_DB(db(Pedido), 'pedido.id',
>>>                                             lambda r: '%s - referencia:
>>> %s' % (r.produto_id.cliente_nome,
>>>
>>>        r.ordem_de_servico))
>>>
>>> Note, r.produto_id.cliente_nome is a recursive select (it will result in
>>> an additional database query for each item in the dropdown list).
>>>
>>> Also, why isn't pedido_id a reference field?
>>>
>>> Note, you can avoid manually specifying the IS_IN_DB validators if you
>>> instead make all of the relevant fields reference fields and then specify
>>> the "format" argument of the two referenced tables (i.e., the "label"
>>> arguments you are using in the IS_IN_DB validators can instead be specified
>>> as the "format" arguments in the definitions of the respective referenced
>>> tables). In that case, web2py will automatically define the IS_IN_DB
>>> validators for you.
>>>
>>> Anthony
>>>
>>>
>>> On Wednesday, June 20, 2018 at 10:40:18 AM UTC-4, Diego Tostes wrote:
>>>>
>>>> I have those tables:
>>>>
>>>> *Produto = db.define_table('produto',*
>>>> *    Field('ficha_tecnica', 'upload', label=T("Ficha Tecnica")),*
>>>> *    Field('cliente_id', 'integer', label=T("Cliente ID")),*
>>>> *    Field('cliente_nome', 'string', label=T("Nome Cliente"))*
>>>> *)*
>>>>
>>>> *Pedido = db.define_table('pedido',*
>>>> *    Field('produto_id', db.produto),*
>>>> *    Field('ordem_de_servico', 'string', label=T("Ordem de Servico")),*
>>>> *    Field('tipo_de_pedido', 'integer', label=T("Tipo de Pedido"))*
>>>> *)*
>>>>
>>>> *Materia_Prima = db.define_table('materia_prima',*
>>>> *    Field('pedido_id', 'integer', label=T("ID DO PEDIDO")),*
>>>> *    Field('data_recebimento', 'date', label=T("Data Recebimento")),*
>>>> *)*
>>>>
>>>> *#requires*
>>>> *Pedido.produto_id.requires = IS_IN_DB(db(Produto), 'produto.id
>>>> <http://produto.id>', '%(cliente_nome)s - referencia: %(referencia)s')*
>>>> *Materia_Prima.pedido_id.requires = IS_IN_DB(db(Pedido), 'pedido.id
>>>> <http://pedido.id>', )*
>>>>
>>>>
>>>> I need that the field Materia_Prima.pedido_id, persist the pedido_id
>>>> but when i select in the dropdow of a SQLFORM the information is:
>>>>
>>>>
>>>> *'%(cliente_nome)s - referencia: %(ordem_de_servico)s'  *
>>>>
>>>> but the field *cliente_nome* is a filed from *Produto*.
>>>>
>>>> is it Possible?
>>>>
>>>>
>>>> Rgds
>>>>
>>>> Diego
>>>>
>>>>
>>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> 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/d/optout.
>>>
>>
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to