[IMP] portal,*: clean chatter setup

* Consistent use of _get_page_view_values
* specify object rendering value as well in the method
* docstring improvements

Part-of: odoo/odoo#84644
This commit is contained in:
Victor Feyens
2022-02-28 14:46:56 +00:00
committed by Yannick Tivisse
parent 213e0ba734
commit 36d7f38e42
6 changed files with 28 additions and 17 deletions
@@ -144,9 +144,7 @@
<!-- chatter -->
<div id="invoice_communication" class="mt-4">
<h2>History</h2>
<t t-call="portal.message_thread">
<t t-set="object" t-value="invoice"/>
</t>
<t t-call="portal.message_thread"/>
</div>
</div>
</div>
+12
View File
@@ -398,6 +398,18 @@ class CustomerPortal(Controller):
return document_sudo
def _get_page_view_values(self, document, access_token, values, session_history, no_breadcrumbs, **kwargs):
"""Include necessary values for portal chatter & pager setup (see template portal.message_thread).
:param document: record to display on portal
:param str access_token: provided document access token
:param dict values: base dict of values where chatter rendering values should be added
:param str session_history: key used to store latest records browsed on the portal in the session
:param bool no_breadcrumbs:
:return: updated values
:rtype: dict
"""
values['object'] = document
if access_token:
# if no_breadcrumbs = False -> force breadcrumbs even if access_token to `invite` users to register if they click on it
values['no_breadcrumbs'] = no_breadcrumbs
+12 -2
View File
@@ -538,10 +538,20 @@
the message will be posted with the identity of the partner_id of the object
:hash : signed token with the partner_id using `_sign_token` method (on mail.thread)
:pid : identifier of the partner signing the token
NOTE: for standard portal flows, _get_page_view_values should be used to properly setup the template parameters
-->
<template id="message_thread">
<div id="discussion" data-anchor="true" class="d-print-none o_portal_chatter o_not_editable p-0"
t-att-data-token="token" t-att-data-res_model="object._name" t-att-data-pid="pid" t-att-data-hash="hash" t-att-data-res_id="object.id" t-att-data-pager_step="message_per_page or 10" t-att-data-allow_composer="'0' if disable_composer else '1'" t-att-data-two_columns="'true' if two_columns else 'false'">
<div id="discussion" data-anchor="true"
class="d-print-none o_portal_chatter o_not_editable p-0"
t-att-data-token="token"
t-att-data-res_model="object._name"
t-att-data-pid="pid"
t-att-data-hash="hash"
t-att-data-res_id="object.id"
t-att-data-pager_step="message_per_page or 10"
t-att-data-allow_composer="'0' if disable_composer else '1'"
t-att-data-two_columns="'true' if two_columns else 'false'">
</div>
</template>
@@ -310,12 +310,7 @@
<div class="mt32" id="task_chat" data-anchor="true">
<h4><strong>Message and communication history</strong></h4>
<t t-call="portal.message_thread">
<t t-set="object" t-value="task"/>
<t t-set="token" t-value="task.access_token"/>
<t t-set="pid" t-value="pid"/>
<t t-set="hash" t-value="hash"/>
</t>
<t t-call="portal.message_thread"/>
</div>
</div>
</div>
+1 -3
View File
@@ -185,9 +185,7 @@
<!-- chatter -->
<div id="purchase_order_communication" class="mt-4">
<h2>History</h2>
<t t-call="portal.message_thread">
<t t-set="object" t-value="order"/>
</t>
<t t-call="portal.message_thread"/>
</div>
</div><!-- // #quote_content -->
</div>
+1 -3
View File
@@ -355,9 +355,7 @@
<!-- chatter -->
<div id="sale_order_communication" class="mt-4">
<h2>History</h2>
<t t-call="portal.message_thread">
<t t-set="object" t-value="sale_order"/>
</t>
<t t-call="portal.message_thread"/>
</div>
</div><!-- // #quote_content -->
</div>