[FIX] base_search_mail_content: allow messsage_content search only for internal users

pull/1385/head
Aungkokolin1997 2023-08-21 08:29:40 +06:30
parent 98e6818e75
commit 310bf06576
4 changed files with 36 additions and 11 deletions

View File

@ -67,6 +67,15 @@ Usage
Go to any model that contains a chatter (e.g. Contacts, ...). Search for
content in field 'Message Content'.
Known issues / Roadmap
======================
- This module restricts the message_content search functionality to
internal users only, addressing the issue faced by project
collaborators (portal users) as described in
https://github.com/OCA/social/issues/1204. Consequently, portal users
no longer have the ability to search within mail content.
Bug Tracker
===========

View File

@ -44,7 +44,11 @@ class MailThread(models.AbstractModel):
that inherits mail.thread
"""
res = super().get_view(view_id=view_id, view_type=view_type, options=options)
if view_type == "search" and self._fields.get("message_content"):
if (
view_type == "search"
and self._fields.get("message_content")
and self.env.user.has_group("base.group_user")
):
doc = etree.XML(res["arch"])
for node in doc.xpath("/search/field[last()]"):
# Add message_content in search view

View File

@ -0,0 +1 @@
- This module restricts the message_content search functionality to internal users only, addressing the issue faced by project collaborators (portal users) as described in <https://github.com/OCA/social/issues/1204>. Consequently, portal users no longer have the ability to search within mail content.

View File

@ -390,11 +390,12 @@ body, email from, reply to and record name.</p>
<ul class="simple">
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
@ -409,8 +410,18 @@ mail.message: subject, body, record_name, email_from, reply_to.</p>
<p>Go to any model that contains a chatter (e.g. Contacts, …). Search for
content in field Message Content.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>This module restricts the message_content search functionality to
internal users only, addressing the issue faced by project
collaborators (portal users) as described in
<a class="reference external" href="https://github.com/OCA/social/issues/1204">https://github.com/OCA/social/issues/1204</a>. Consequently, portal users
no longer have the ability to search within mail content.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
@ -418,9 +429,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
<li>SerpentCS</li>
@ -428,7 +439,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
@ -443,7 +454,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose