SOLVED: The solution I've found is not the prettiest but it works (and I'm glad and I like it). As the problem with the many2many fields in record rules seems to persists, I have removed them. Instead, in every object I want to restrict, I have overriden the search method forcing it to take into account the restriction on departments.
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: context = {} res = self._get_partner_ids(cr, uid, args, context) args.append(('partner_id','in', res)) return super(res_partner, self).search(cr, uid, args, offset, limit, order, context=context, count=count) def _get_partner_ids(self, cr, uid, args, context=None): """Get a list of partner visible by current user""" cr.execute('select distinct partner_id from hr_department_partner_rel where department_id in (select department_id from hr_department_user_rel where user_id = %s)', (uid,)) resultSet = cr.fetchall() res = [] for result in resultSet: res.append(result[0]) return res Sorry I'm not a Python guy (yet) and the code can be improved but this works for all the views where partners are listed. ------------------------ Jose A. Corbacho Trobz (www.trobz.com) -------------------- m2f -------------------- -- http://www.openobject.com/forum/viewtopic.php?p=50935#50935 -------------------- m2f -------------------- _______________________________________________ Tinyerp-users mailing list http://tiny.be/mailman2/listinfo/tinyerp-users
