On Saturday, January 23, 2016 at 1:22:52 AM UTC-5, Seraaj Muneer wrote: > > It appears that placing the 'common_filter' in the table definition > together with the speical field 'request_tenant' is problematic. However, > doing > > > db.bank.common_filter = lambda query: db.bank.company_id == > get_default_company_id() > > > > > This shouldn't make a difference, nor do I think it should be a problem to use both request_tentant and common_filter together. Above, you have specified db.bank.common_filter rather than db.bank._common_filter, so your above code isn't actually implementing a filter at all.
Note, your combination of request_tenant and common_filter requires that there are records where request_tentant matches auth.user_id *and* company_id matches the value returned by get_default_company_id. Is it possible that there are simply no records that meet those two conditions? Also, why bother with request_tenant here at all? You've already got auth.signature in the table definition, and setting request_tenant equal to auth.user_id is equivalent to applying a filter where created_by (or modified_by) is equal to auth.user_id. So you could just add that to your common filter. Finally, you can get rid of your _before_insert callback and instead simply set the default value of the company_id field directly: Field(company_id_field, 'reference company', default=get_default_company_id ()) Anthony -- 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.

