[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
This commit is contained in:
Martin Trigaux
2018-09-18 10:51:10 +02:00
parent 69af1df70a
commit 6dec0bc308
+2 -3
View File
@@ -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: