From 54e970e7105436ab757dff279444d4c6970654d2 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Tue, 16 Apr 2019 13:32:22 +0000 Subject: [PATCH] [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) --- addons/calendar/models/mail_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/calendar/models/mail_message.py b/addons/calendar/models/mail_message.py index 426c7a78d52..3d5b6dcae00 100644 --- a/addons/calendar/models/mail_message.py +++ b/addons/calendar/models/mail_message.py @@ -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)