[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) <xbo@odoo.com>
This commit is contained in:
Hugo Carlier (Huca)
2023-08-04 09:42:55 +02:00
parent 29a1b46afb
commit 825df5c5f5
3 changed files with 38 additions and 5 deletions
@@ -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',
+20 -3
View File
@@ -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()
@@ -21,7 +21,23 @@
</group>
<field name="note" placeholder="Add a note" nolabel="1"/>
<footer>
<button string="Send" name="action_send_mail" attrs="{'invisible': [('access_warning', '!=', '')]}" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Send" name="action_share_record" attrs="{'invisible': [('access_warning', '!=', '')]}" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Discard" class="btn-secondary" special="cancel" data-hotkey="x" />
</footer>
</form>
</field>
</record>
<record id="project_share_wizard_confirm_form" model="ir.ui.view">
<field name="name">project.share.wizard.view.form</field>
<field name="model">project.share.wizard</field>
<field name="arch" type="xml">
<form string="Confirmation">
<p>People invited to collaborate on the project will have portal access rights.</p>
<p>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.</p>
<p>You have full control and can revoke portal access anytime. Are you ready to proceed?</p>
<footer>
<button string="Grant Portal Access" name="action_send_mail" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Discard" class="btn-secondary" special="cancel" data-hotkey="x" />
</footer>
</form>