in mail.message model _read_group_raw function is overridden as:
@api.model
def _read_group_raw(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if not self.env.is_admin():
raise AccessError(_("Only administrators are allowed to use grouped read on message model"))
return super(Message, self)._read_group_raw(
domain=domain, fields=fields, groupby=groupby, offset=offset,
limit=limit, orderby=orderby, lazy=lazy,
)
Now I want to override it to avoid the access error. but when returning super(), the parent function will be read and raise an AccessError. Is any way to override this function to avoid raising exception but use super and dont write the base function completely?
There is better way, but it may have some consequences.
@api.model
def _read_group_raw(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
res = super(Message, self.sudo())._read_group_raw(
domain=domain, fields=fields, groupby=groupby, offset=offset,
limit=limit, orderby=orderby, lazy=lazy,
)
# Your code
return res
is guess in this line:
res = super(Message, self.sudo())._read_group_raw(
the exception will occure.