[FIX] calendar: browse record using IrRules
Create a calendar meeting using Mark Demo. In the options of the event, set the meeting as "Show Time as" = "Free". Using the admin user, send a digest (KPI Digest module, technical > emails > digest email > send now). It raises an User Error because the template cannot be rendered. The problem is due to the way the "Show Time as" is implemented, the "Free" option is used to not show the meeting in the different calendar views. The events are hidden thanks to a record rule "Hide Private Meetings". Each digest is sent using the context of each subscripted user and not the SuperUser ID 1. The call to `search_count` on `mail.message` calls the dedicated `_search` of `mail.message` and ultimately end up in the overriden `_find_allowed_model_wise` method of message in calendar. That method does a browse of all the record ids containing new messages in their chatter, but fail with an access error due to the above record rule. Because it fails, the `kpi_mail_message_total_value` compute fails and the field is missing when rendering the template. Using `search` instead of `browse` ensures records unavailable due to a record rule are filtered out. opw-1966664 closes odoo/odoo#32735 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -28,6 +28,7 @@ class Message(models.Model):
|
||||
def _find_allowed_model_wise(self, doc_model, doc_dict):
|
||||
if doc_model == 'calendar.event':
|
||||
order = self._context.get('order', self.env[doc_model]._order)
|
||||
for virtual_id in self.env[doc_model].browse(doc_dict).get_recurrent_ids([], order=order):
|
||||
records = self.env[doc_model].search([('id', 'in', list(doc_dict))])
|
||||
for virtual_id in records.get_recurrent_ids([], order=order):
|
||||
doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)])
|
||||
return super(Message, self)._find_allowed_model_wise(doc_model, doc_dict)
|
||||
|
||||
Reference in New Issue
Block a user