Hi,
I have a scenerio in which I have multiple companies (company1,company2,company3 all are individual companies) when a user logs in who is of company1 (he has company1 and company2 in his allowed companies field), He must see all the partners related to company1 and company2 (i.e based on allowed companies).
By default the access right is:
['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]
I modified it to:
['|',('company_id,'in',[user.company_ids.id]),('company_id','=',False)]
But it dint worked. An error is thrown. Can anyone have a solution for this. Please help me with a solution.
Following below is my access rule:
['|',('company_id,'in',([user.company_ids.id])),('company_id','=',False)]
Following is the error message:
Server Traceback (most recent call last): File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/ir/ir_ui_menu.py", line 340, in get_needaction_data res[menu.id]['needaction_counter'] = obj._needaction_count(cr, uid, dom, context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/ir/ir_needaction.py", line 64, in _needaction_count res = self.search(cr, uid, (domain or []) + dom, limit=100, order='id DESC', context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base_calendar/crm_meeting.py", line 134, in search return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 2372, in search return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/portal/mail_message.py", line 45, in _search context=context, count=count, access_rights_uid=access_rights_uid) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/mail/mail_message.py", line 604, in _search context=context, count=False, access_rights_uid=access_rights_uid) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 4935, in _search query = self._where_calc(cr, user, args, context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 4761, in _where_calc e = expression.expression(cr, user, domain, self, context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/expression.py", line 646, in __init__ self.parse(cr, uid, context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/expression.py", line 845, in parse right_ids = relational_model.search(cr, uid, [(field_path[1], operator, right)], context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 2372, in search return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/res/res_partner.py", line 594, in _search count=count, access_rights_uid=access_rights_uid) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 4936, in _search self._apply_ir_rules(cr, user, query, 'read', context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 4816, in _apply_ir_rules rule_where_clause, rule_where_clause_params, rule_tables = rule_obj.domain_get(cr, uid, self._name, mode, context=context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/ir/ir_rule.py", line 150, in domain_get dom = self._compute_domain(cr, uid, model_name, mode) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/tools/cache.py", line 18, in lookup r = self.lookup(self2, cr, *args) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/tools/cache.py", line 46, in lookup value = d[key] = self.method(self2, cr, *args) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/ir/ir_rule.py", line 130, in _compute_domain rule_domain = self.read(cr, uid, rule.id, ['domain'])['domain'] File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 3679, in read result = self._read_flat(cr, user, select, fields, context, load) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/orm.py", line 3800, in _read_flat res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/osv/fields.py", line 1145, in get result = self._fnct(obj, cr, uid, ids, name, self._arg, context) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/addons/base/ir/ir_rule.py", line 53, in _domain_force_get res[rule.id] = expression.normalize_domain(eval(rule.domain_force, eval_context)) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/tools/safe_eval.py", line 285, in safe_eval return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict) File "/home/endo/Downloads/openerp-7.0-20140804-231303/openerp/tools/safe_eval.py", line 158, in test_expr code_obj = compile(expr, "", mode) File "<string>", line 1 ['|',('company_id,'in',([user.company_ids.id])),('company_id','=',False)] ^ SyntaxError: invalid syntax
Thank you in advance.
Regards,
Emon.