From 2573d681dd64fde0f36d3ca2cda32ab21e0a62aa Mon Sep 17 00:00:00 2001 From: jvm-odoo Date: Wed, 18 Mar 2020 08:30:22 +0000 Subject: [PATCH] [FIX] calendar: fix virtual ids present when recomputing models Issue - Install Calendar, HR Recruitment & Studio - Go into Calendar - Create a recurring event - Edit it with Studio - Add a related field - Select Applicant > Assigned Traceback Cause Applicant > Assigned is a stored field. Adding a stored field seems to triggers something that recomputes all models odoo/odoo:odoo/modules/registry.py@12.0#L307 Then it calls the _write method of models.py which uses self.ids (which contains virtuals ids) for a SQL query. odoo/odoo:odoo/models.py@12.0#L3428 Solution Avoid all the virtuals ids to be retrieved when we have "update_custom_fields" in the context. OPW-2214170 closes odoo/odoo#48208 X-original-commit: 112f976eb193020c093068fd30a004be3f5e9254 Signed-off-by: Jason Van Malder (jvm) --- addons/calendar/models/calendar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 1007c1457b4..2d7fad4224b 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1751,7 +1751,9 @@ class Meeting(models.Model): new_arg = (arg[0], arg[1], get_real_ids(arg[2])) new_args.append(new_arg) - if not self._context.get('virtual_id', True): + # update_custom_fields: context used by the ORM to check if custom fields (studio) should be updated + virtual_id_fallback = not self._context.get('update_custom_fields') + if not self._context.get('virtual_id', virtual_id_fallback): return super(Meeting, self)._search(new_args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid) if any(arg[0] == 'start' for arg in args) and \