It can be used in a model, but only after you define auth and auth tables
(auth.define_tables)

Marin


On Mon, Sep 23, 2013 at 11:54 PM, 黄祥 <[email protected]> wrote:

> thank you so much for your explaination.
> my code is work now when i define it in controller.
>
> 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
>
> it seems the auth_user can't work in models, because the models execute
> first than the authentication check for the value.
> i think all related to database (in this case field constructor), must be
> put in models.
>
> 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.
>

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