From 22f4aa1c4341cd2e8008b730f676473f025cbb42 Mon Sep 17 00:00:00 2001 From: Denis Ledoux <dle@odoo.com> Date: Wed, 25 May 2016 18:16:40 +0200 Subject: [PATCH] [FIX] crm: merge leads in multi-company When merging leads with a company set different than the current user company, it failed because the notification email (the message written in the thread summarizing the merge) couldn't read the company name (the `name_get` call on the company) because of the multi-company record rule. `name_get` can be safely called as `sudo`, as it does nothing else than returning the name of the record. This is already done for the many2one links in the web client anyway (You can see leads from a company different than yours, you can see the company name to which the leads belongs to, but you can't click on the company many2one link) opw-677986 --- addons/crm/crm_lead.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 711292eb4e3d..f33d4c16ad54 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -528,11 +528,11 @@ class crm_lead(format_address, osv.osv): value = dict(key).get(lead[field_name], lead[field_name]) elif field.type == 'many2one': if lead[field_name]: - value = lead[field_name].name_get()[0][1] + value = lead[field_name].sudo().name_get()[0][1] elif field.type == 'many2many': if lead[field_name]: for val in lead[field_name]: - field_value = val.name_get()[0][1] + field_value = val.sudo().name_get()[0][1] value += field_value + "," else: value = lead[field_name] -- GitLab