From 825df5c5f5c2a77262fd08e5fcf6daf74da13c72 Mon Sep 17 00:00:00 2001 From: "Hugo Carlier (Huca)" Date: Wed, 26 Jul 2023 13:48:36 +0000 Subject: [PATCH] [IMP] project: generate a portal user when sharing a project Currently, when the creation of an user access is set to `invitation only` in the website settings, a project shared to a partner with no user account will not be accessible to that partner. The link sent to this partner will instead redirect him to the homepage of the website. This commit address this situation by allowing the partner that receive the link to create a portal access. The user that share the project is warned that partners will be able to create user accounts and offered the option to proceed or not. task-3356419 closes odoo/odoo#129790 Signed-off-by: Xavier Bol (xbo) --- .../tests/tours/project_sharing_tour.js | 2 +- addons/project/wizard/project_share_wizard.py | 23 ++++++++++++++++--- .../wizard/project_share_wizard_views.xml | 18 ++++++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/addons/project/static/tests/tours/project_sharing_tour.js b/addons/project/static/tests/tours/project_sharing_tour.js index e74ef58c870..2cf1ed3aafa 100644 --- a/addons/project/static/tests/tours/project_sharing_tour.js +++ b/addons/project/static/tests/tours/project_sharing_tour.js @@ -21,7 +21,7 @@ const projectSharingSteps = [...stepUtils.goToAppSteps("project.menu_main_pm", ' trigger: '.ui-autocomplete a.dropdown-item:contains("Georges")', in_modal: false, }, { - trigger: 'footer > button[name="action_send_mail"]', + trigger: 'footer > button[name="action_share_record"]', content: 'Confirm the project sharing with this portal user.', }, { trigger: '.o_web_client', diff --git a/addons/project/wizard/project_share_wizard.py b/addons/project/wizard/project_share_wizard.py index 80ec5c9e053..1efed798eaf 100644 --- a/addons/project/wizard/project_share_wizard.py +++ b/addons/project/wizard/project_share_wizard.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import api, fields, models, _ class ProjectShareWizard(models.TransientModel): @@ -43,13 +43,30 @@ class ProjectShareWizard(models.TransientModel): else: wizard.resource_ref = None - def action_send_mail(self): + def action_share_record(self): + # Confirmation dialog is only opened if new portal user(s) need to be created in a 'on invitation' website self.ensure_one() + on_invite = self.env['res.users']._get_signup_invitation_scope() == 'b2b' + new_portal_user = self.partner_ids.filtered(lambda p: not p.user_ids) and on_invite + if not new_portal_user: + return self.action_send_mail() + return { + 'name': _('Confirmation'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'views': [(self.env.ref('project.project_share_wizard_confirm_form').id, 'form')], + 'res_model': 'project.share.wizard', + 'res_id': self.id, + 'target': 'new', + 'context': self.env.context, + } + + def action_send_mail(self): if self.access_mode == 'edit': portal_partners = self.partner_ids.filtered('user_ids') self.resource_ref._add_collaborators(self.partner_ids) self._send_public_link(portal_partners) - self._send_signup_link(partners=self.partner_ids - portal_partners) + self._send_signup_link(partners=self.with_context({'signup_valid': True}).partner_ids - portal_partners) self.resource_ref.message_subscribe(partner_ids=self.partner_ids.ids) return {'type': 'ir.actions.act_window_close'} return super().action_send_mail() diff --git a/addons/project/wizard/project_share_wizard_views.xml b/addons/project/wizard/project_share_wizard_views.xml index 512dba38029..f42284c4e4f 100644 --- a/addons/project/wizard/project_share_wizard_views.xml +++ b/addons/project/wizard/project_share_wizard_views.xml @@ -21,7 +21,23 @@
-
+ +
+ + + + project.share.wizard.view.form + project.share.wizard + +
+

People invited to collaborate on the project will have portal access rights.

+

They can edit shared project tasks and view specific documents in read-only mode on your website. This includes leads/opportunities, quotations/sales orders, purchase orders, invoices and bills, timesheets, and tickets.

+

You have full control and can revoke portal access anytime. Are you ready to proceed?

+