From 6dec0bc308616fb4c5818470c7fed112bde2517c Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 18 Sep 2018 10:26:43 +0200 Subject: [PATCH] [FIX] calendar: compare display_name for empty recordset When sorting by a many2many fields (e.g. partner_ids) with one of the record having an empty value on the sorted field, the comparison method used to compare and empty record (e.g. res.partner()) and a name_get result (e.g. "Agrolait"). This is because the sort_field was initialized with the result of self[field] but never assigned a new value below. Fallback on an empty string when no record is found Fixes #26908 --- addons/calendar/models/calendar.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 0653621ed96..629f4bb00c7 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -997,9 +997,8 @@ class Meeting(models.Model): else: sort_fields[field] = self[field] if isinstance(self[field], models.BaseModel): - name_get = self[field].name_get() - if len(name_get) and len(name_get[0]) >= 2: - sort_fields[field] = name_get[0][1] + name_get = self[field].mapped('display_name') + sort_fields[field] = name_get and name_get[0] or '' if r_date: sort_fields['sort_start'] = r_date.strftime(VIRTUALID_DATETIME_FORMAT) else: