Serpentcs
8 years ago
7 changed files with 278 additions and 0 deletions
-
83mail_message_name_search/README.rst
-
83mail_message_name_search/README.rst~
-
7mail_message_name_search/__init__.py
-
20mail_message_name_search/__openerp__.py
-
24mail_message_name_search/data/trgm_index_data.xml
-
7mail_message_name_search/models/__init__.py
-
54mail_message_name_search/models/mail_message.py
@ -0,0 +1,83 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
======================== |
||||
|
Mail message name search |
||||
|
======================== |
||||
|
|
||||
|
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 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. |
||||
|
|
||||
|
|
||||
|
Installation |
||||
|
============ |
||||
|
|
||||
|
This module depends on the module 'base_search_fuzzy' to ensure that |
||||
|
searches on emails are based on indexes. Please read carefully the install |
||||
|
instructions https://github.com/OCA/server-tools/blob/8.0/base_search_fuzzy/README.rst |
||||
|
|
||||
|
This module installs by default the indexes that are required to |
||||
|
perform the searches on mail messages. |
||||
|
|
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
|
||||
|
No configuration is needed. |
||||
|
|
||||
|
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. |
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/server-tools/9.0 |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues |
||||
|
<https://github.com/OCA/social/issues>`_. In case of trouble, please |
||||
|
check there if your issue has already been reported. If you spotted it first, |
||||
|
help us smashing it by providing a detailed and welcomed feedback. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Images |
||||
|
------ |
||||
|
|
||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Jordi Ballester Alomar <jordi.ballester@eficent.com> |
||||
|
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose |
||||
|
mission is to support the collaborative development of Odoo features and |
||||
|
promote its widespread use. |
||||
|
|
||||
|
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,83 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
======================== |
||||
|
Mail message name search |
||||
|
======================== |
||||
|
|
||||
|
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 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. |
||||
|
|
||||
|
|
||||
|
Installation |
||||
|
============ |
||||
|
|
||||
|
This module depends on the module 'base_search_fuzzy' to ensure that |
||||
|
searches on emails are based on indexes. Please read carefully the install |
||||
|
instructions https://github.com/OCA/server-tools/blob/8.0/base_search_fuzzy/README.rst |
||||
|
|
||||
|
This module installs by default the indexes that are required to |
||||
|
perform the searches on mail messages. |
||||
|
|
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
|
||||
|
No configuration is needed. |
||||
|
|
||||
|
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. |
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/server-tools/8.0 |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues |
||||
|
<https://github.com/OCA/social/issues>`_. In case of trouble, please |
||||
|
check there if your issue has already been reported. If you spotted it first, |
||||
|
help us smashing it by providing a detailed and welcomed feedback. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Images |
||||
|
------ |
||||
|
|
||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Jordi Ballester Alomar <jordi.ballester@eficent.com> |
||||
|
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose |
||||
|
mission is to support the collaborative development of Odoo features and |
||||
|
promote its widespread use. |
||||
|
|
||||
|
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,7 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Eficent Business and IT Consulting Services S.L. |
||||
|
# (http://www.eficent.com) |
||||
|
# © 2016 Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import models |
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Eficent Business and IT Consulting Services S.L. |
||||
|
# (http://www.eficent.com) |
||||
|
# © 2016 Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
{ |
||||
|
"name": "Mail message name search", |
||||
|
"version": "9.0.1.0.0", |
||||
|
"author": "Eficent," |
||||
|
"SerpentCS," |
||||
|
"Odoo Community Association (OCA)", |
||||
|
"website": "http://www.eficent.com", |
||||
|
"category": "Social", |
||||
|
"data": ["data/trgm_index_data.xml"], |
||||
|
"depends": ["mail", |
||||
|
"base_search_fuzzy"], |
||||
|
"license": "AGPL-3", |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data noupdate="1"> |
||||
|
|
||||
|
<record id="subject_gin_idx" model="trgm.index"> |
||||
|
<field name="index_type">gin</field> |
||||
|
<field name="field_id" |
||||
|
search="[('model','=','mail.message'),('name','=','subject')]"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="body_gin_idx" model="trgm.index"> |
||||
|
<field name="index_type">gin</field> |
||||
|
<field name="field_id" |
||||
|
search="[('model','=','mail.message'),('name','=','body')]"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="record_name_gin_idx" model="trgm.index"> |
||||
|
<field name="index_type">gin</field> |
||||
|
<field name="field_id" |
||||
|
search="[('model','=','mail.message'),('name','=','record_name')]"/> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,7 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Eficent Business and IT Consulting Services S.L. |
||||
|
# (http://www.eficent.com) |
||||
|
# © 2016 Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from . import mail_message |
@ -0,0 +1,54 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Eficent Business and IT Consulting Services S.L. |
||||
|
# (http://www.eficent.com) |
||||
|
# © 2016 Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>) |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from openerp import api, models |
||||
|
from lxml import etree |
||||
|
from openerp.osv import expression |
||||
|
|
||||
|
|
||||
|
_base_fields_view_get = models.BaseModel.fields_view_get |
||||
|
|
||||
|
|
||||
|
@api.model |
||||
|
def _custom_fields_view_get(self, view_id=None, view_type='form', |
||||
|
toolbar=False, submenu=False): |
||||
|
# Tricky super call |
||||
|
res = _base_fields_view_get(self, view_id=view_id, view_type=view_type, |
||||
|
toolbar=toolbar, submenu=submenu) |
||||
|
if view_type == 'search' and self._fields.get('message_ids'): |
||||
|
doc = etree.XML(res['arch']) |
||||
|
for node in doc.xpath("//field[1]"): |
||||
|
elem = etree.Element('field', { |
||||
|
'name': 'message_ids', |
||||
|
'domain': "[('model','=', %s)]" % self._model |
||||
|
}) |
||||
|
node.addnext(elem) |
||||
|
res['fields'].update({ |
||||
|
'message_ids': { |
||||
|
'type': 'many2one', |
||||
|
'relation': 'mail.message', |
||||
|
'string': 'Messages', |
||||
|
} |
||||
|
}) |
||||
|
res['arch'] = etree.tostring(doc) |
||||
|
return res |
||||
|
|
||||
|
models.BaseModel.fields_view_get = _custom_fields_view_get |
||||
|
|
||||
|
|
||||
|
class MailMessage(models.Model): |
||||
|
|
||||
|
_inherit = 'mail.message' |
||||
|
|
||||
|
@api.model |
||||
|
def name_search(self, name='', args=None, operator='ilike', limit=100): |
||||
|
args = args or [] |
||||
|
domain = ['|', '|', ('record_name', operator, name), |
||||
|
('subject', operator, name), ('body', operator, name)] |
||||
|
if operator in expression.NEGATIVE_TERM_OPERATORS: |
||||
|
domain = domain[2:] |
||||
|
rec = self.search(domain + args, limit=limit) |
||||
|
return rec.name_get() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue