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.