Hard to say what's going on. Looks like it's getting an empty string from
an ID field. What does the db.clientes definition look like?
On Monday, July 2, 2018 at 7:38:27 AM UTC-4, Diego Tostes wrote:
>
> Hi,
>
> i have this table:
>
> def tempo_total_produto(produto_id):
> try:
> query = ((db.produto.id == produto_id))
> result = db(query).select()
> data_status = result[0]["data_criacao"]
>
> data_hoje = datetime.date.today()
> retorno = abs((data_hoje - data_status).days)
> except:
> retorno = "sem data"
> return retorno
>
>
> Produto = db.define_table('produto',
> Field('ficha_tecnica', 'upload', label=T("Ficha Tecnica")),
> Field('descricao_produto', 'string', label=T("Descricao Produto")),
> Field('foto_frente', 'upload', label=T("Foto Frente")),
> Field('foto_costas', 'upload', label=T("Foto Costas")),
> Field('foto_detalhe', 'upload', label=T("Foto Detalhe")),
> Field('cliente_id', db.clientes, label=T("Cliente ID")),
> Field('data_criacao', 'date', default=datetime.date.today,
> label=T("Data Criacao Produto")),
> Field('referencia', 'string', label=T("Referencia")),
> Field('colecao', 'string', label=T("Colecao")),
> Field('previsao_entrega', 'date', label=T("Previsão Entrega")),
> Field('cronoanalise', 'integer', label=T("Cronoanálise")),
> Field('custo', 'double', label=T("Custo Producao")),
> Field('preco_venda', 'double', label=T("Preco Venda")),
> Field('qtd_estimada', 'integer', label=T("Qtd Estimada")),
> Field('lacrado', 'boolean', label=T("LACRADO")),
> Field('finalizado', 'boolean', label=T("FINALIZADO")),
> Field('cancelado', 'boolean', label=T("CANCELADO")),
> Field.Virtual('tempo_total', lambda row: tempo_total_produto(
> row.produto.id)),
> )
>
>
> #REQUIRES
> Produto.cliente_id.requires = IS_IN_DB(db(Clientes), 'clientes.id',
> '%(nome_cliente)s')
>
>
> It is possible create and show a Produto using SQLFORM, but i am getting a
> error when i am trying to edit.
>
>
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
> 29.
> 30.
> 31.
> 32.
> 33.
> 34.
> 35.
> 36.
>
> Traceback (most recent call last):
> File "/home/modasustentavel/web2py/gluon/restricted.py", line 227, in
> restricted
> exec ccode in environment
> File
> "/home/modasustentavel/web2py/applications/modasustentavel/controllers/default.py"
>
> <https://modasustentavel.pythonanywhere.com/admin/edit/modasustentavel/controllers/default.py>,
> line 677, in <module>
> File "/home/modasustentavel/web2py/gluon/globals.py", line 417, in <lambda>
> self._caller = lambda f: f()
> File "/home/modasustentavel/web2py/gluon/tools.py", line 4241, in f
> return action(*a, **b)
> File
> "/home/modasustentavel/web2py/applications/modasustentavel/controllers/default.py"
>
> <https://modasustentavel.pythonanywhere.com/admin/edit/modasustentavel/controllers/default.py>,
> line 240, in cadastro_produto
> maxtextlength=64,paginate=40)
> File "/home/modasustentavel/web2py/gluon/sqlhtml.py", line 2346, in grid
> update_form = SQLFORM(table, record, **sqlformargs)
> File "/home/modasustentavel/web2py/gluon/sqlhtml.py", line 1295, in __init__
> inp = self.widgets.options.widget(field, default)
> File "/home/modasustentavel/web2py/gluon/sqlhtml.py", line 313, in widget
> options = requires[0].options()
> File "/home/modasustentavel/web2py/gluon/validators.py", line 598, in
> options
> self.build_set()
> File "/home/modasustentavel/web2py/gluon/validators.py", line 584, in
> build_set
> records = self.dbset(table).select(*fields, **dd)
> File "/home/modasustentavel/web2py/gluon/packages/dal/pydal/objects.py",
> line 2020, in select
> return adapter.select(self.query, fields, attributes)
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1296, in select
> return self._select_aux(sql,fields,attributes)
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1277, in _select_aux
> return processor(rows,fields,self._colnames,cacheable=cacheable)
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1767, in parse
> for row in rows]
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1677, in _parse
> value = self.parse_value(value, ft, blob_decode)
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1527, in parse_value
> return self.parsemap[key](value,field_type)
> File
> "/home/modasustentavel/web2py/gluon/packages/dal/pydal/adapters/base.py",
> line 1622, in parse_id
> return long(value)
> ValueError: invalid literal for long() with base 10: ''
>
>
>
>
> Any idea to fiz this ?
>
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.