From 3da19480b24ee6c12569e77bd765ad561cc2e312 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Tue, 5 Feb 2019 09:23:58 +0000 Subject: [PATCH] [FIX] calendar: do not try to read virtual ids from database Try to access a recurring event. The _search function defined in mail_message tries to read records, building a list of ids. They are given to the _search of calendar, which builds its custom SQL query using the data it received. Since it got recurring ids instead of real ones, we get: SELECT id, ("calendar_event"."id" in (101,'101-2019011118000... Bug introduced in f74f5edc7778a3afacc454c31993ac8502d3d0ee. If we get such a request, we convert the virtual ids back to real ids. Note that a similar conversion was done in calendar's override of "mail.message" _search method, 'in the case it was asked on virtual ids'. Note that as of this commit making messages on virtual_ids doesn't even work, so it is possible that this mess was introduced for the chatter feature, which has been broken before, and so all of it is useless. closes #27474 closes #28288 closes #28621 opw 1928562 opw 1930763 opw 1935148 closes odoo/odoo#30827 --- addons/calendar/models/calendar.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index ef717319aef..677afec01c0 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1129,6 +1129,9 @@ class Meeting(models.Model): select_fields = ["id"] where_params_list = [] for pos, arg in enumerate(domain): + # hack: if we received recurrent ids, we need to clean them + if arg[0] == 'id' and arg[1] in ('in', 'not in'): + arg = (arg[0], arg[1], [calendar_id2real_id(id) for id in arg[2]]) if not arg[0] in ('start', 'stop', 'final_date', '&', '|'): e = expression.expression([arg], self) where_clause, where_params = e.to_sql() # CAUTION, wont work if field is autojoin, not supported