summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorMitali Patel <mpa@odoo.com>2017-12-15 14:38:02 +0530
committerDavid Beguin <dbe@odoo.com>2018-08-03 15:20:42 +0200
commit84f528bcff12e39b5ed172a4789aab27c9f89a19 (patch)
tree747f84c680e2a1a122ac190792d4a2d7b07612ef /addons/mail
parent766a1025b1ba25ef40897418fac662eaa42d3a0f (diff)
[IMP] Portal - Share link : Easily share the url of a document
Purpose ======= - Quickly share the url to someone else (a client, a colleague,...) - Ensure that the recipient can access at least the portal view of the shared record. - Typically used when a client cannot retrieve the mail to access his order. The share link can be used in this case. Specifications ============== For any object inheriting form portal.mixin: - Add a button SHARE (not visible in edit mode) - When clicking on this button, a popup opens with : - A warning message for tasks and projects only (see below) - the link (like in gmail) that can be copied - Recipients - mail composer (with preselected template) ==> see below - button [Send Link] [Copy Link] Discard - After sharing document, put internal note like "Document shared to xyz,...." with template message - Anyone with the link, even anonymous user (not logged in) can have access to the document with the access token provided in the url. Impacted models: - account.invoice (Community) - project.project (Community) - project.task (Community) - purchase.order (Community) - sale.order (Community) - helpdesk.ticket (Enterprise) Warning messages and access rules: Allowed : - SO canceled or draft will be accessible with the link with access_token - If the customer account is B2B (signup not enabled), the recipient will anyway see the document as the user specifically wants the recipient to see the document. Restrictions : - For Project and Task, if the privacy is not public, then, there is a contradiction between the access_token mechanism and the privacy of the document. - A warning message will be displayed in the share wizard to inform the user if the document cannot be visible by the recipients and to ask him to set the privacy to 'Visible by following customer'. The send button will, in that case, be hidden. - To avoid to block the share for a new project, default privacy value is now set to 'Visible by followong customer' Technical implementation ======================== - Move the access_token mechanism (field + methods + mail controller) to the portal.mixin to be able to use it in a generic way for each object inheriting the portal.mixin - Generalise a part of the _*model*_get_page_view_values method into a single one in portal - Generalize the _*model*_check_access into the portal controller of the portal module - Remove the init_column + default value for the access_token > old records have an access_token, > new one won't but it will be generated on demand via the get_access_token Done for performance reasons - Add share button into action menu separately. + kanban view context menu (except for task and project where button not in action menu but 'simple' button for task and project because other modules already provide action to send documents by email, which is not the case for project and task.) - Add a sign_token used to authentify the recipient in the portal view chatter, if any. The message will be posted as if the user was logged in. - Set the _get_share_url as private for security reason - Add a redirect parameter to _get_share_url to get If false : The direct portal view url If True : The redirect url (mail/view/?) - Cleaning up unnecessary code - Bug fix : - Before, if user was not logged and record had partner_id, if partner id was null, post message was done as admin. Now, the post message is done as public user. - If the user had an uid but had no access_token, he could be able to gain the access token of the record. check_access_rights was missing in the get_access_action. Task ID : 30985 Closes #25629
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/controllers/main.py6
-rw-r--r--addons/mail/data/mail_data.xml4
2 files changed, 6 insertions, 4 deletions
diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index 949a715cddb..1600189c7b9 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -49,7 +49,9 @@ class MailController(http.Controller):
return comparison, record, redirect
@classmethod
- def _redirect_to_record(cls, model, res_id, access_token=None):
+ def _redirect_to_record(cls, model, res_id, access_token=None, **kwargs):
+ # access_token and kwargs are used in the portal controller override for the Send by email or Share Link
+ # to give access to the record to a recipient that has normally no access.
uid = request.session.uid
# no model / res_id, meaning no possible record -> redirect to login
@@ -178,7 +180,7 @@ class MailController(http.Controller):
"""
if res_id and isinstance(res_id, pycompat.string_types):
res_id = int(res_id)
- return self._redirect_to_record(model, res_id, access_token)
+ return self._redirect_to_record(model, res_id, access_token, **kwargs)
@http.route('/mail/assign', type='http', auth='user', methods=['GET'])
def mail_action_assign(self, model, res_id, token=None):
diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml
index c499dd5c5e7..7af17890aae 100644
--- a/addons/mail/data/mail_data.xml
+++ b/addons/mail/data/mail_data.xml
@@ -229,7 +229,7 @@
<!-- Information on model to use this notification template
* if the record has an online access defined in get_access_action, having
- a get_mail_url methods is required (like sale order and invoice);
+ a _get_share_url methods is required (like sale order and invoice);
* this template works best with portal-enable models although it is not
a complete requirement currently;
-->
@@ -242,7 +242,7 @@
<td align="center" style="min-width: 590px;">
<t t-set="access_action" t-value="record.with_context(force_website=True).get_access_action()"/>
<t t-set="is_online" t-value="access_action and access_action['type'] == 'ir.actions.act_url'"/>
- <t t-set="access_url" t-value="is_online and record.get_mail_url() or ''"/>
+ <t t-set="access_url" t-value="is_online and record._get_share_url(redirect=True, signup_partner=True) or ''"/>
<t t-set="access_code" t-value="'view'"/>
<t t-set="access_name" t-value="'View %s' % (record._description.lower())"/>
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">