[web2py] Re: model define_table select

2017-01-12 Thread Pierre Corbeil
Good day Luca/Massimo,
Can you show me the final code ..i'am trying to do exactly that. 
(unsure of what you have done exactly in db.py)
Thanks

Le lundi 28 mars 2016 05:51:33 UTC-4, lucas a écrit :
>
> yes massimo,
>
> that almost worked.  as suggested, i first changed it under the db.py 
> model and then set the request.vars.state_id to the state_id variable just 
> before creating and assigning the SQLFORM under the controller module.  it 
> threw back an empty set of counties.  so i thought maybe request isn't 
> reaching that deep into the db.py module.  so i changed the request.vars 
> into session, like session.state_id = state_id, and also under db.py and 
> that worked great.
>
> i am always amazed of how fast and efficiently i can get things done using 
> web2py.  it really is a wonder and wonderful.
>
> thanx massimo.  lucas
>
> On Sunday, March 27, 2016 at 11:17:19 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Correction. replace
>>
>> IS_IN_DB(db_region(*db_region.post.state_id==db_region.county.state_id*)
>>
>> with
>>
>> IS_IN_DB(db_region(*db_region.county.state_id == **request.vars.state_id*
>> )
>>
>

-- 
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.


[web2py] IS_IN_SET or IS_IN_DB to create a sublist based on part of a table

2017-01-05 Thread Pierre Corbeil
Trying to migrate my old access environment to web2py.  I have imported all 
data, can be viewed ok.
Trying to get a dropdown list (when using smargrid) that is a subset of a 
table.
been trying for while now,  maybe someone can give me a hint.
Here is the tables :

#
db.define_table('famille' ,
  Field('famille' ,'string' , label='Famille' , length = 
25),format='%(famille)s')
#
db.define_table('detail'  ,
  Field('famille' ,'reference famille'),
  Field('detail'  ,'string' , label='Detail'   , length = 
60),format='%(detail)s')
#
db.define_table('achat',   
   # not showing all the fields to shortens the text a bit
  Field('famille' ,'reference famille' , label='Famille'),   # 
shows as a drop down pick list, works ok
  Field('detail'  ,'reference detail'  , label='Détail' ), 
 # show sall the detail, but I would like to view only the ones related to 
the "famille" that has just been selected
  Field('dcc' ,'boolean'   , label='Payer ce mois'))
#
# The controler, as it is now:
def manage():
db.achat.id.readable=False
db.achat.qui.represent  = lambda v, r: '' if v is None else 
(db.qui(v).prenom)
db.achat.typ.represent  = lambda v, r: '' if v is None else 
(db.typ(v).typ)
db.achat.famille.represent  = lambda v, r: '' if v is None else 
(db.famille(v).famille)
db.achat.detail.represent   = lambda v, r: '' if v is None else 
(db.detail(v).detail)
grid = SQLFORM.smartgrid(db.achat, 
 linked_tables=['qui','typ','famille','detail','famdet'],
fields=[db.achat.quand,
db.achat.montant,
db.achat.cash,
db.achat.qui,
db.achat.commun,
db.achat.typ,
db.achat.note,
db.achat.famille,
db.achat.detail,
db.achat.dcc ],
orderby=~db.achat.quand,
create=False,
exportclasses= dict(csv_with_hidden_cols=False, 
tsv_with_hidden_cols=False, tsv=False, json=False, xml=False, html=False),
paginate=10)
return locals()


-- 
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.