Hi! `belongs` accepts list, tuple, SQL-string (that can be generated by `_select `) and in some cases it may be a `query` (see book for details) but you're trying to feed it with field-object
On Thursday, January 3, 2019 at 11:39:34 AM UTC+3, Yann Dulondel wrote: > > > > Le mercredi 2 janvier 2019 16:55:54 UTC+1, Yann Dulondel a écrit : >> >> Hi All >> Happy new year 2019. >> >> I have an issue with SQL NOT IN >> I tried to get a heater pad list(dropdown) in a form. >> The heater must be related to user depot and not been used. >> If they are used the heater id is set up in table articles >> >> Queryheat=db((db.heatpad.id_depot==db.auth_user.id_depot)&(db.auth_user. >> id==auth.user.id))&db(~db.heatpad.id.belongs(db.articles.heatpad)) >> >> I always get an exception memory error >> I have tried with >> Queryheat=db((db.heatpad.id_depot==db.auth_user.id_depot)&(db.auth_user. >> id==auth.user.id)&db(~db.heatpad.id.belongs(db.articles.heatpad).select( >> db.heatpad.id))) >> Queryheat=db((db.heatpad.id_depot==db.auth_user.id_depot)&(db.auth_user. >> id==auth.user.id)&(~db.heatpad.id.belongs(db.articles.heatpad).select(db. >> heatpad.id))) >> >> The goal is to generate a SQL commande >> > SELECT X,Y from t1,t2 where t1.id=t2.fkid and x not in( select id from > t3) > > > def show_flexi(): >> request.title=T("Braid Logistics Europe") >> flexi_id=request.args(0, cast=int) >> type_article=request.args(1, cast=int) >> records = db.articles(flexi_id) >> db.articles.cod_ref.writable=False >> db.articles.id_stk_article.readable=db.articles.id_stk_article. >> writable=False >> db.articles.id.readable=False >> db.articles.isintegrated.readable=db.articles.isintegrated.writable= >> False >> depotrecord=db(db.depot.id==auth.user.id_depot).select(db.depot. >> useheatpad) >> Row=depotrecord[0] >> if Row['useheatpad']==True: >> myFields=['cod_ref','conteneur','dossier','date_sortie','bulk_id' >> ,'detruit','heatpad'] >> Queryheat=db((db.heatpad.id_depot==db.auth_user.id_depot)&(db. >> auth_user.id==auth.user.id))&db(~db.heatpad.id.belongs(db.articles. >> heatpad)) >> db.articles.heatpad.requires=IS_IN_DB(Queryheat,db.heatpad.id, >> '%(cod_ref)s') >> else: >> myFields=['cod_ref','conteneur','dossier','date_sortie', >> 'bulk_id','detruit'] >> QueryLang=db((db.depot.id==db.auth_user.id_depot)&(db.type_bulkhead. >> id_language==db.depot.id_lang)&(db.auth_user.id==auth.user.id)) >> db.articles.bulk_id.requires=IS_IN_DB(QueryLang,db.type_bulkhead.id, >> '%(name)s') >> #labels={'cod_ref':T('Flexi Number'),'conteneur':T('Conteneur >> Number'),'dossier':T('Braid reference'),'date_sortie':T('Fitting >> date'),'bulk_id':T('Bulkhead'),'detruit':T('Destroyed')} >> flexi=SQLFORM(db.articles >> ,record=records >> #,labels=labels >> ,fields=myFields) >> #,searchable=False) >> >> >> flexi.add_button(T('Back'), URL(show_flexlist,args=[type_article], >> user_signature=True)) >> if flexi.process(onvalidation=flexivalidation).accepted: >> response.flash = T('form accepted') >> >> #redirect(URL(show_flexlist,args=[type_article],user_signature=True)) >> elif flexi.errors: >> response.flash = T('Form has errors') >> >> >> return(dict(message=flexi_id,flexi=flexi)) >> Any idea where i'm wrong ? >> Yann >> >> >> -- 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.