Browse Source

[IMP] search by email_from and reply_to

Introduce search of html fields
Create indexes
Update Readme
pull/143/head
ahenriquez 8 years ago
parent
commit
fba0d9a189
  1. 45
      base_search_mail_content/README.rst
  2. 5
      base_search_mail_content/__openerp__.py
  3. 12
      base_search_mail_content/data/trgm_index_data.xml
  4. 6
      base_search_mail_content/models/mail_thread.py
  5. 17
      base_search_mail_content/views/trgm_index_view.xml

45
base_search_mail_content/README.rst

@ -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
body of the message. This will be useful in models that make intense use of
messages, like project issues or helpdesk tickets.
This module adds the capability to find any object (e.g. project issues or
helpdesk ticket) based on the conversation threads associated to them.
This module will add dynamically the message_ids to the search view of
any model that inherits from the mail.thread and will incorporate the
capability to search for content in the mail messages.
This will be useful in models that make intense use of messages,
like project issues or helpdesk tickets.
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,
based on the conversations that the person responsible for the ticket
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.
Go to any model that contains a chatter (e.g. Partners, Leads, ...). Search
for content in field 'Message Content'.
.. 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
---------- ----------

5
base_search_mail_content/__openerp__.py

@ -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",

12
base_search_mail_content/data/trgm_index_data.xml

@ -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>

6
base_search_mail_content/models/mail_thread.py

@ -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:]

17
base_search_mail_content/views/trgm_index_view.xml

@ -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>
Loading…
Cancel
Save