:D wel olny crud.create doesn't work
this is the track
Traceback (most recent call last):
File "/home/drayco/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
File "/home/drayco/web2py/applications/opticaluz/controllers/
ventas.py", line 1086, in <module>
File "/home/drayco/web2py/gluon/globals.py", line 95, in <lambda>
self._caller = lambda f: f()
File "/home/drayco/web2py/gluon/tools.py", line 2315, in f
return action(*a, **b)
File "/home/drayco/web2py/applications/opticaluz/controllers/
ventas.py", line 1056, in realizar_venta
return dict(form=crud.create(db.notas, next=URL(r=request,
f='leer_ventas'), onvalidation=procesing_nota,
onaccept=procesing_taller))
File "/home/drayco/web2py/gluon/tools.py", line 2889, in create
deletable=False,
File "/home/drayco/web2py/gluon/tools.py", line 2805, in update
formstyle=self.settings.formstyle
File "/home/drayco/web2py/gluon/sqlhtml.py", line 792, in __init__
inp = self.widgets.options.widget(field, default)
File "/home/drayco/web2py/gluon/sqlhtml.py", line 205, in widget
options = requires[0].options()
File "/home/drayco/web2py/gluon/validators.py", line 2350, in
_options
options = self.other.options()
File "/home/drayco/web2py/gluon/validators.py", line 424, in options
self.build_set()
File "/home/drayco/web2py/gluon/validators.py", line 408, in
build_set
records = self.dbset.select(*self.fields, **dd)
File "/home/drayco/web2py/gluon/sql.py", line 4369, in select
return self.db._adapter.select(self.query,fields,attributes)
File "/home/drayco/web2py/gluon/sql.py", line 976, in select
query = self._select(query,fields,attributes)
File "/home/drayco/web2py/gluon/sql.py", line 911, in _select
raise SyntaxError, 'Set: no tables selected'
SyntaxError: Set: no tables selected
And the code of the controller is
def realizar_venta():
return dict(form=crud.create(db.notas, next=URL(r=request,
f='leer_ventas'), onvalidation=procesing_nota,
onaccept=procesing_taller))
On Dec 8, 10:30 pm, drayco <[email protected]> wrote:
> Hi, I updated trunk version, but error still happens, but now all my
> functions that use crud.(search,read,create) doesn't work
>
> this the track
>
> Traceback (most recent call last):
> File "/home/drayco/web2py/gluon/restricted.py", line 188, in
> restricted
> exec ccode in environment
> File "/home/drayco/web2py/applications/opticaluz/controllers/
> gerencia.py", line 1417, in <module>
> File "/home/drayco/web2py/gluon/globals.py", line 95, in <lambda>
> self._caller = lambda f: f()
> File "/home/drayco/web2py/gluon/tools.py", line 2315, in f
> return action(*a, **b)
> File "/home/drayco/web2py/applications/opticaluz/controllers/
> gerencia.py", line 278, in ventas
> if form.accepts(request.vars,session):
> File "/home/drayco/web2py/gluon/sqlhtml.py", line 1159, in accepts
> self.vars.id = self.table.insert(**fields)
> File "/home/drayco/web2py/gluon/sql.py", line 3735, in insert
> return new_fields
> File "/home/drayco/web2py/gluon/sql.py", line 690, in insert
> query = self._insert(table,fields)
> AttributeError: 'BaseAdapter' object has no attribute 'cursor'
>
> On Dec 8, 9:48 pm, mdipierro <[email protected]> wrote:
>
> > Thanks for your tests. One more time please.
>
> > On Dec 8, 9:37 pm, drayco <[email protected]> wrote:
>
> > > Hi, I updated trunk version, but error still happens
>
> > > this the track
>
> > > Traceback (most recent call last):
> > > File "/home/drayco/web2py/gluon/restricted.py", line 188, in
> > > restricted
> > > exec ccode in environment
> > > File "/home/drayco/web2py/applications/opticaluz/controllers/
> > > gerencia.py", line 1417, in <module>
> > > File "/home/drayco/web2py/gluon/globals.py", line 95, in <lambda>
> > > self._caller = lambda f: f()
> > > File "/home/drayco/web2py/gluon/tools.py", line 2315, in f
> > > return action(*a, **b)
> > > File "/home/drayco/web2py/applications/opticaluz/controllers/
> > > gerencia.py", line 278, in ventas
> > > if form.accepts(request.vars,session):
> > > File "/home/drayco/web2py/gluon/sqlhtml.py", line 1159, in accepts
> > > self.vars.id = self.table.insert(**fields)
> > > File "/home/drayco/web2py/gluon/sql.py", line 3735, in insert
> > > return self._db._adapter.insert(self,self._listify(fields))
> > > File "/home/drayco/web2py/gluon/sql.py", line 690, in insert
> > > raise e
> > > AttributeError: 'BaseAdapter' object has no attribute 'cursor'
>
> > > On Dec 8, 9:07 pm, mdipierro <[email protected]> wrote:
>
> > > > I think this is now fixed. Please give it a try.
>
> > > > On Dec 8, 6:42 pm, drayco <[email protected]> wrote:
>
> > > > > Hi this the code in the controller:
>
> > > > > def form_factory(*a):
> > > > > return SQLFORM(SQLDB(None).define_table(*a))
>
> > > > > def ventas():
> > > > > form=form_factory('myform',
>
> > > > > SQLField('inicio','date',default=request.now.date(),requires=IS_NOT_EMPTY()),
> > > > > SQLField('fin','date',default=request.now.date()))
> > > > > total=''
> > > > > regs=''
> > > > > totalcorte=''
> > > > > cortesias=''
> > > > > totalc=''
> > > > > cancel=''
> > > > > totalgaran=''
> > > > > garantias=''
> > > > > totalcero=''
> > > > > cero=''
> > > > > inicio = ''
> > > > > fin = ''
> > > > > if form.accepts(request.vars,session):
> > > > > response.flash='Formulario aceptado'
> > > > > from datetime import datetime
> > > > > inicio = datetime.strptime(str(form.vars.inicio) + "
> > > > > 00:00:00", "%Y-%m-%d %H:%M:%S")
> > > > > if form.vars.fin==None:
> > > > > fin = inicio
> > > > > fin = fin.replace(hour=23,minute=59,second=59)
> > > > > else:
> > > > > fin = datetime.strptime(str(form.vars.fin) + " 23:59:59",
> > > > > "%Y-%m-%d %H:%M:%S")
> > > > > Gerente = db.auth_user(user_id)
> > > > > total =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia==None)&(db.notas.vale==None)).
> > > > > \
>
> > > > > select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> > > > > db.notas.id.count()),\
> > > > > headers={'COUNT(notas.id)':'Num.Notas',
> > > > > 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> > > > > 'SUM(notas.pagos)':'Pagos',
> > > > > 'SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> > > > > COUNT(notas.id)':'Promedio'})
> > > > > regs =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> > > > > ==
> > > > > Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia==None)&(db.notas.vale==None)).
> > > > > \
>
> > > > > select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> > > > > db.notas.id.count(),\
> > > > > orderby=~(db.notas.total.sum()/
> > > > > db.notas.id.count()),groupby=db.notas.vendedor),\
>
> > > > > headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Num.Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> > > > > COUNT(notas.id)':'Promedio'})
> > > > > totalc =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==False)).
> > > > > \
>
> > > > > select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> > > > > \
> > > > > headers={'COUNT(notas.id)':'Num.Notas',
> > > > > 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> > > > > 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
> > > > > cancel =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> > > > > == Gerente.store_id)&(db.notas.active==False)).\
>
> > > > > select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),
> > > > > \
> > > > > orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> > > > > headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo'})
> > > > > totalcorte =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.vale!
> > > > > =None)).\
>
> > > > > select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> > > > > \
> > > > > headers={'COUNT(notas.id)':'Num.Notas',
> > > > > 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> > > > > 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
> > > > > cortesias =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> > > > > == Gerente.store_id)&(db.notas.active==True)&(db.notas.vale!=None)).\
>
> > > > > select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),
> > > > > \
> > > > > orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> > > > > headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo'})
> > > > > totalgaran =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> > > > > =None)).\
>
> > > > > select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> > > > > db.notas.id.count()),\
> > > > > headers={'COUNT(notas.id)':'Num.Notas',
> > > > > 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> > > > > 'SUM(notas.pagos)':'Pagos',
> > > > > 'SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> > > > > COUNT(notas.id)':'Promedio'})
> > > > > garantias =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> > > > > == Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> > > > > =None)).\
>
> > > > > select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> > > > > db.notas.id.count(),\
> > > > > orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> > > > > headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> > > > > COUNT(notas.id)':'Promedio'})
> > > > > totalcero =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.total==0)).
> > > > > \
>
> > > > > select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> > > > > \
> > > > > headers={'COUNT(notas.id)':'Notas',
> > > > > 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> > > > > 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
> > > > > cero =
> > > > > SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> > > > > == Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> > > > > =None)&(db.notas.vale!=None)&(db.notas.total==0)).\
>
> ...
>
> read more »