[IMP] search by email_from and reply_to

Introduce search of html fields
Create indexes
Update Readme
This commit is contained in:
ahenriquez 2017-01-10 12:37:11 +01:00 committed by Eduardo De Miguel
parent 66014fdfb2
commit 72f5d20abf
5 changed files with 61 additions and 24 deletions

View File

@ -3,43 +3,45 @@
:alt: License: AGPL-3 :alt: License: AGPL-3
======================== ========================
Mail message name search Base Search Mail Content
======================== ========================
This module adds the capability to search for mail messages by subject or This module adds the capability to find any object (e.g. project issues or
body of the message. This will be useful in models that make intense use of helpdesk ticket) based on the conversation threads associated to them.
messages, like project issues or helpdesk tickets.
This module will add dynamically the message_ids to the search view of This will be useful in models that make intense use of messages,
any model that inherits from the mail.thread and will incorporate the like project issues or helpdesk tickets.
capability to search for content in the mail messages.
A project issue or helpdesk ticket can contain tens of mails or notes
associated, based on the feedback that the person responsible for the ticket
maintains, including conversations with the person that raised the issue.
A user may often want to find issues or tickets, based on the past
conversations that were recorded, as much as he/she needs to search
in their mail for past conversations.
This module will add dynamically a field 'message_content' to the search view of
any model that inherits from the mail.thread.
The current search capabilities include searching into the subject, body,
email from, reply to and record name.
Installation Installation
============ ============
This module depends on the module 'base_search_fuzzy' to ensure that This module depends on the module 'base_search_fuzzy' to ensure that
searches on emails are based on indexes. Please read carefully the install searches on emails are based on indexes. Please read carefully the install
instructions https://github.com/OCA/server-tools/blob/9.0/base_search_fuzzy/README.rst instructions:
https://github.com/OCA/server-tools/blob/9.0/base_search_fuzzy/README.rst
This module installs by default the indexes that are required to This module installs by default the indexes that are required to
perform the searches on mail messages. perform the searches on mail messages.
Configuration
=============
No configuration is needed.
Usage Usage
===== =====
A project issue or helpdesk ticket can contain tens of mails associated, Go to any model that contains a chatter (e.g. Partners, Leads, ...). Search
based on the conversations that the person responsible for the ticket for content in field 'Message Content'.
maintains with the person that raised the issue. One need to search
in mail messages, as much as he/she needs to search in their mail for
past conversations. So this module will be useful for the user to search
messages by subject or body.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
@ -66,6 +68,9 @@ Contributors
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> * Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
* Lois Rilo Antelo <lois.rilo@eficent.com>
* Aaron Henriquez <ahenriquez@eficent.com>
Maintainer Maintainer
---------- ----------

View File

@ -5,14 +5,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Mail message name search", "name": "Base Mail Search Content",
"version": "9.0.1.0.0", "version": "9.0.1.0.0",
"author": "Eficent," "author": "Eficent,"
"SerpentCS," "SerpentCS,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "http://www.eficent.com", "website": "http://www.eficent.com",
"category": "Social", "category": "Social",
"data": ["data/trgm_index_data.xml"], "data": ["data/trgm_index_data.xml",
"views/trgm_index_view.xml"],
"depends": ["mail", "depends": ["mail",
"base_search_fuzzy"], "base_search_fuzzy"],
"license": "AGPL-3", "license": "AGPL-3",

View File

@ -20,5 +20,17 @@
search="[('model','=','mail.message'),('name','=','record_name')]"/> search="[('model','=','mail.message'),('name','=','record_name')]"/>
</record> </record>
<record id="email_from_gin_idx" model="trgm.index">
<field name="index_type">gin</field>
<field name="field_id"
search="[('model','=','mail.message'),('name','=','email_from')]"/>
</record>
<record id="reply_to_gin_idx" model="trgm.index">
<field name="index_type">gin</field>
<field name="field_id"
search="[('model','=','mail.message'),('name','=','reply_to')]"/>
</record>
</data> </data>
</openerp> </openerp>

View File

@ -15,9 +15,11 @@ class MailThread(models.AbstractModel):
_inherit = 'mail.thread' _inherit = 'mail.thread'
def _search_message_content(self, operator, value): def _search_message_content(self, operator, value):
domain = [('model', '=', self._name), '|', '|', domain = [('model', '=', self._name), '|', '|', '|', '|',
('record_name', operator, value), ('record_name', operator, value),
('subject', operator, value), ('body', operator, value)] ('subject', operator, value), ('body', operator, value),
('email_from', operator, value),
('reply_to', operator, value)]
if operator in expression.NEGATIVE_TERM_OPERATORS: if operator in expression.NEGATIVE_TERM_OPERATORS:
domain = domain[2:] domain = domain[2:]

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="trgm_index_view_form">
<field name="name">trgm.index.view.form</field>
<field name="model">trgm.index</field>
<field name="inherit_id" ref="base_search_fuzzy.trgm_index_view_form"/>
<field name="arch" type="xml">
<field name="field_id" position="attributes">
<attribute name="domain">[('ttype', 'in', ['char', 'text', 'html'])]</attribute>
</field>
</field>
</record>
</data>
</openerp>