From 59dc90ce16ecd1f8ffee0e313ff0815e8c67aff6 Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Thu, 9 Sep 2021 13:17:39 +0000 Subject: [PATCH] [FIX] mail: sets the proper record name for `mail.channel.partner` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the addition of guests, it isn't enough to rely on the `partner_id` of the record to get the name. This commit adds an override of `name_get` so that the `display_name` of the record remains consistent for both partners and guests. closes odoo/odoo#76329 X-original-commit: 48d3f78ee3fd796907e17319607f19b8c97ba9c3 Signed-off-by: Sébastien Theys (seb) --- addons/mail/models/mail_channel_partner.py | 4 +++- addons/mail/views/mail_channel_partner_views.xml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_channel_partner.py b/addons/mail/models/mail_channel_partner.py index c9cf5275982..b65fede4643 100644 --- a/addons/mail/models/mail_channel_partner.py +++ b/addons/mail/models/mail_channel_partner.py @@ -11,7 +11,6 @@ class ChannelPartner(models.Model): _name = 'mail.channel.partner' _description = 'Listeners of a Channel' _table = 'mail_channel_partner' - _rec_name = 'partner_id' # identity partner_id = fields.Many2one('res.partner', string='Recipient', ondelete='cascade', readonly=True, index=True) @@ -29,6 +28,9 @@ class ChannelPartner(models.Model): last_interest_dt = fields.Datetime("Last Interest", default=fields.Datetime.now, help="Contains the date and time of the last interesting event that happened in this channel for this partner. This includes: creating, joining, pinning, and new message posted.") rtc_inviting_session_id = fields.Many2one('mail.channel.rtc.session', string='Ringing session') + def name_get(self): + return [(record.id, record.partner_id.name or record.guest_id.name) for record in self] + def _remove_rtc_invitation(self): """ Removes the invitation to the rtc call and notifies the inviting partner if removed. """ notifications = [] diff --git a/addons/mail/views/mail_channel_partner_views.xml b/addons/mail/views/mail_channel_partner_views.xml index f48f416f642..32bb2891da7 100644 --- a/addons/mail/views/mail_channel_partner_views.xml +++ b/addons/mail/views/mail_channel_partner_views.xml @@ -7,7 +7,7 @@ 10 - + @@ -22,6 +22,7 @@ +