hm, it's strange, because i define it on the models after i define auth
table. i define custom auth table in db.py and put the default value that
refer to custom auth table in db_wizard_warehouse_transaction.py (the same
definition that work when i define it on controller). if i'm not wrong
web
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, 黄祥 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.
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
you are not logged in in the shell. that's why auth.user_id is None and so
you can't fetch the corresponding auth_user record
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/l
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.a
meaning, you should use *first()*, not *first*
On Monday, September 23, 2013 6:09:47 PM UTC+2, Marin Pranjić wrote:
>
> First is a method, not an attribute.
>
> Marin (mobile)
>
> On Sep 23, 2013 5:06 PM, "黄祥" >
> wrote:
>
> hi,
>
> i want to have default value for table field that refer to custo
First is a method, not an attribute.
Marin (mobile)
On Sep 23, 2013 5:06 PM, "黄祥" wrote:
hi,
i want to have default value for table field that refer to custom auth_user
field for current user login.
i tried something like:
auth_user_branch = db(db.auth_user.id == auth.user_id).select().first
hi,
i want to have default value for table field that refer to custom auth_user
field for current user login.
i tried something like:
auth_user_branch = db(db.auth_user.id == auth.user_id).select().first
#db.stock_movement_header.from_branch.default=auth_user_branch.branch
#db.stock_movement_hea
8 matches
Mail list logo