Worked, thank you! Em quarta-feira, 13 de junho de 2018 13:17:00 UTC-3, Anthony escreveu: > > db.SaidaProdutoEstoque.ID_EntradaProdutoEstoque.requires = >> IS_IN_DB(db(db.EntradaProdutoEstoque.Ativo == True), >> db.EntradaProdutoEstoque, db.EntradaProdutoEstoque._format) >> >> I want the table *SaidaProdutoEstoque* on field >> *ID_EntradaProdutoEstoque* show *Lote *and the product name referenced >> on table *EntradaProdutoEstoque *on Field *ID_Produto *where the name of >> product is on table *Produto* >> >> It's possible? >> > > Yes, but you cannot simply use db.EntradaProdutoEstoque._format, as that > will only show the ID_Produto integer value. Instead, the third argument > to IS_IN_DB can be a function: > > db.SaidaProdutoEstoque.ID_EntradaProdutoEstoque.requires = IS_IN_DB( > db(db.EntradaProdutoEstoque.Ativo == True), > db.EntradaProdutoEstoque, > lambda r: '%s - %s' % (r.Lote, r.ID_Produto.ProdutoDescricao)) > > Note, r.ID_Produto.ProdutoDescricao is a recursive select > <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Recursive-selects> > > -- it results in a separate select query for each item in the list. If > there are many items, this may be inefficient and slow. If that becomes a > problem, an alternative is to retrieve the data you need for the > validator/widget via a SQL join, and then use an IS_IN_SET validator with > a manually generated set of items. > > Also, note that r.ID_Produto.ProdutoDescricao is equivalent to > db.Produto(r.ID_Produto).ProdutoDescricao. > > Anthony >
-- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

