i've tried that too, but still get an error :

#auth_user_branch = db(db.auth_user.id == 
auth.user_id).select(db.auth_user.branch).first()
#db.stock_movement_header.from_branch.default=auth_user_branch.branch
#AttributeError: 'NoneType' object has no attribute 'branch'

#auth_user_branch = db(db.auth_user.id == auth.user_id).select().first()
#db.stock_movement_header.from_branch.default=auth_user_branch.branch
#AttributeError: 'NoneType' object has no attribute 'branch'

#db.stock_movement_header.from_branch.default=auth.user_branch
#AttributeError: 'Auth' object has no attribute 'user_branch'

#db.stock_movement_header.from_branch.default=auth.user_id.branch
#AttributeError: 'NoneType' object has no attribute 'branch'

#db.stock_movement_header.from_branch.default=session.auth.user.branch
#AttributeError: 'NoneType' object has no attribute 'user'

#db.stock_movement_header.from_branch.default=session.auth_user.branch
#AttributeError: 'NoneType' object has no attribute 'branch'

testing query in shell with user logged in :
In [1] : print db(db.auth_user.id == 
auth.user_id).select(db.auth_user.branch).first()
None

In [2] : print db(db.auth_user.id == auth.user_id).select().first()
None

In [3] : print db(db.auth_user.id == 1).select(db.auth_user.branch).first()
<Row {'branch': 1L}>

here is the custom auth_user table :
auth.settings.extra_fields['auth_user']=[
    Field('gender', notnull=True),
    Field('address', 'text'),
    Field('zip_code'),
    Field('city'),
    Field('country'),
    Field('phone', 'list:string', notnull=True),
    Field('branch', 'reference branch', notnull=True),
    Field('department', 'reference department', notnull=True)]

auth.define_tables(username=True, signature=True)

i define default value in models, is it affected the result?
any hints how to retrieve value from custom auth_user field for current 
user login?

thanks and best regards,
stifan

>

-- 
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/groups/opt_out.

Reply via email to