In tree view I show record where is user_id = uid and for that use:
<field name="domain">[('user_id.id','=',uid)]</field>
I need allow administrator to see all record without domain filter.
Any simple solution?
You can do it using following method.
Remove domain from the action & Inherit search method in python file.
from openerp import models,fields,api,_
from openerp.exceptions import Warning
from openerp.osv import expression
from openerp import SUPERUSER_ID
class mail_message(models.Model):
_inherit = 'mail.message'
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False, access_rights_uid=None):
""" Override that adds specific access rights of mail.message, to restrict
messages to published messages for public users. """
if uid!=SUPERUSER_ID:
args = expression.AND([[('user_id', '=',uid)], list(args)])
return super(mail_message, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
context=context, count=count, access_rights_uid=access_rights_uid)
When action will execute _search will be called, in which you can check if user_id is SUPERUSER_ID then do not add domain or add domain.
This may help you.
ir.rule
aka access rules. There are some easy to understand examples in thesale
module of odoo for the modelsale.order
. – CZoellner