Skip to Content
Menu
This question has been flagged
4 Replies
5898 Views

Hi all,

i need to make a record rule for purchase order and manufacturing order that show record only to the one who create the record and those who is added as followers

for user own record i set a record rule with  [('create_uid', '=', user.id)] and works fine.

i'm struggling with the followers rule , something like [('message_is_follower','=', [user.id])] but don't work.
any suggestion?


thanks

Avatar
Discard

you need message_partner_id ?

Best Answer

Hello Mauro,

Try this :

[('message_is_follower','=',1)]

Thanks,

Mayank Gosai

Avatar
Discard
Best Answer

Hello in Odoo V10,

use for show record which is created by user and also he is a set follower in other record,

at my side bolow code[domain in rule] work perfectly.

['|',('create_uid','=',user.id),('message_partner_ids', 'in', [user.partner_id.id])]

Avatar
Discard
Author

this is what i got

Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 546, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 583, in dispatch

result = self._call_function(**self.params)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 319, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper

return f(dbname, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in checked_call

return self.endpoint(*a, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 812, in __call__

return self.method(*args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 412, in response_wrap

response = f(*args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 878, in load_needaction

return request.session.model('ir.ui.menu').get_needaction_data(menu_ids, request.context)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 917, in proxy

result = meth(cr, request.uid, *args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_menu.py", line 345, in get_needaction_data

res[menu.id]['needaction_counter'] = obj._needaction_count(cr, uid, dom, context=context)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/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 "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1650, in search

return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4688, in _search

self._apply_ir_rules(cr, user, query, 'read', context=context)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4553, 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 "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_rule.py", line 155, in domain_get

query = self.pool[model_name]._where_calc(cr, SUPERUSER_ID, dom, active_test=False)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4498, in _where_calc

e = expression.expression(cr, user, domain, self, context)

File "/usr/lib/python2.7/dist-packages/openerp/osv/expression.py", line 662, in __init__

self.parse(cr, uid, context=context)

File "/usr/lib/python2.7/dist-packages/openerp/osv/expression.py", line 830, in parse

raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))

ValueError: Invalid field 'message_partner_ids' in leaf "<osv.ExtendedLeaf: ('message_partner_ids', 'in', [489]) on purchase_order (ctx: )>"

Sorry for not mention Version,

my code working with Odoo V10.

Thanks.

in your case maybe work below example,

['|', ('user_id', '=', user.id), ('message_follower_ids', '=', user.partner_id.id)]

Author Best Answer

try [('message_is_follower','=',1)] but don't works
it shows every records

this works

[('message_follower_ids', 'in', [user.partner_id.id])]

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 21
1630
1
Jun 20
10061
0
Jul 24
1
1
Dec 21
8773
1
Sep 21
2404