From 0645b7efa903903fd51dd199259c9aff1b2c69ab Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 7 Jul 2020 14:37:45 +0000 Subject: [PATCH] [FIX] crm: prevent having portal user as salesman 1. set a Sales team and add an alias 2. create a contact (customer) with an email and grant them portal access (under the action) 3. Odoo creates a portal user 4. use the email of the contact to send an email to the alias set under the sales team An opportunity is created but the sales person assign to that opportunity is the customer. This will revert user if the user has no access to crm.lead opw-2288442 closes odoo/odoo#54217 X-original-commit: a3fdff3dd9cc38b432b93a7cd4387cb7c38b8d06 Signed-off-by: Nicolas Martinelli (nim) --- addons/crm/models/crm_lead.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index b3adb24281f..d7d352b4efb 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -1306,6 +1306,11 @@ class Lead(models.Model): through message_process. This override updates the document according to the email. """ + + # remove external users + if self.env.user.has_group('base.group_portal'): + self = self.with_context(default_user_id=False) + # remove default author when going through the mail gateway. Indeed we # do not want to explicitly set user_id to False; however we do not # want the gateway user to be responsible if no other responsible is