>
> There is an error in you query -- the "and" should be an "&". But that is 
> not the source of your exception, which comes from the previous line that 
> attempts to access the db.employee table. Apparently, at this point in the 
> code, that table has not yet been defined (perhaps it is defined in a later 
> model file, or defined in a conditional model file).
>
>
the employee table already defined before booking table (file name base 
order), what do you mean with conditional model file? is it related with 
show_if?
e.g.
*models/db_wizard_2_employee.py*
# on_define_employee
def on_define_employee(table): 
# requires
table.auth_user.requires = IS_EMPTY_OR(IS_IN_DB(db, db.auth_user.id, 
'%(first_name)s %(last_name)s') )
# show_if
table.auth_user.show_if = (table.is_auth == True)
table.first_name.show_if = (table.is_auth == False)
table.last_name.show_if = (table.is_auth == False)
table.email.show_if = (table.is_auth == False)

# create table : employee
db.define_table('employee', 
Field('is_auth', 'boolean'),
Field('auth_user', 'reference auth_user'),  
Field('first_name'), 
Field('last_name'), 
Field('email', 'list:string'), 
on_define = on_define_employee, 
format = '%(first_name)s %(last_name)s')

*models/db_wizard_4_booking.py*
employee = db(db.employee.auth_user == auth.user_id).select().first()

# on_define_booking
def on_define_booking(table): 
# requires
table.room.requires = IS_IN_DB(db((db.room.status == 'Available') & 
(db.room.branch == employee.branch)), db.room.id, db.room._format) if 
auth.user else None

# create table : booking
db.define_table('booking', 
Field('booking_no'), 
Field('room', 'reference room'),
on_define = on_define_booking, 
format = '%(booking_no)s')

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/d/optout.

Reply via email to