mirror of https://github.com/OCA/social.git
[MIG] base_search_mail_content: Migration to 17.0
parent
7d64db6e88
commit
105005d646
|
@ -58,13 +58,8 @@ body, email from, reply to and record name.
|
|||
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/15.0/base_search_fuzzy>`__.
|
||||
|
||||
This module installs by default the indexes that are required to perform
|
||||
the searches on mail messages.
|
||||
This module creates the GIN (trigram) indexes for these fields of
|
||||
mail.message: subject, body, record_name, email_from, reply_to.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
@ -104,6 +99,8 @@ Contributors
|
|||
- Vicent Cubells
|
||||
- Ernesto Tejeda
|
||||
|
||||
- Nguyen Minh Chien <chien@trobz.com>
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
{
|
||||
"name": "Base Search Mail Content",
|
||||
"version": "16.0.1.0.2",
|
||||
"version": "17.0.1.0.0",
|
||||
"author": "ForgeFlow, SerpentCS, Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/social",
|
||||
"category": "Social",
|
||||
"data": ["data/trgm_index_data.xml"],
|
||||
"depends": ["mail", "base_search_fuzzy"],
|
||||
"depends": ["mail"],
|
||||
"license": "AGPL-3",
|
||||
"installable": True,
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo 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>
|
||||
|
||||
<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>
|
||||
|
||||
</odoo>
|
|
@ -4,5 +4,5 @@
|
|||
# (<http://www.serpentcs.com>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import mail_message
|
||||
from . import mail_thread
|
||||
from . import trgm_index
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2016 ForgeFlow S.L.
|
||||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# Copyright 2018 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MailMessage(models.Model):
|
||||
_inherit = "mail.message"
|
||||
|
||||
subject = fields.Char(index="trigram")
|
||||
body = fields.Html(index="trigram")
|
||||
record_name = fields.Char(index="trigram")
|
||||
email_from = fields.Char(index="trigram")
|
||||
reply_to = fields.Char(index="trigram")
|
|
@ -1,17 +0,0 @@
|
|||
# Copyright 2016 ForgeFlow S.L.
|
||||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# Copyright 2018 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class TrgmIndex(models.Model):
|
||||
_inherit = "trgm.index"
|
||||
|
||||
# We take advantage of field inheritance to redefine help instead of do
|
||||
# inheritance in views that throws an error
|
||||
field_id = fields.Many2one(
|
||||
help="You can either select a field of type 'text', 'char' or 'html'."
|
||||
)
|
|
@ -5,3 +5,4 @@
|
|||
- [Tecnativa](https://www.tecnativa.com):
|
||||
- Vicent Cubells
|
||||
- Ernesto Tejeda
|
||||
- Nguyen Minh Chien \<<chien@trobz.com>\>
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
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/15.0/base_search_fuzzy).
|
||||
|
||||
This module installs by default the indexes that are required to perform
|
||||
the searches on mail messages.
|
||||
This module creates the GIN (trigram) indexes for these fields of mail.message: subject, body, record_name, email_from, reply_to.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
@ -402,12 +401,8 @@ body, email from, reply to and record name.</p>
|
|||
</div>
|
||||
<div class="section" id="installation">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
|
||||
<p>This module depends on the module ‘base_search_fuzzy’ to ensure that
|
||||
searches on emails are based on indexes. Please read carefully the
|
||||
<a class="reference external" href="https://github.com/OCA/server-tools/blob/15.0/base_search_fuzzy">install
|
||||
instructions</a>.</p>
|
||||
<p>This module installs by default the indexes that are required to perform
|
||||
the searches on mail messages.</p>
|
||||
<p>This module creates the GIN (trigram) indexes for these fields of
|
||||
mail.message: subject, body, record_name, email_from, reply_to.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
||||
|
@ -444,6 +439,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Ernesto Tejeda</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Nguyen Minh Chien <<a class="reference external" href="mailto:chien@trobz.com">chien@trobz.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
|
|
@ -7,7 +7,7 @@ from odoo.tests.common import TransactionCase
|
|||
class TestBaseSearchMailContent(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.channel_obj = self.env["mail.channel"]
|
||||
self.channel_obj = self.env["discuss.channel"]
|
||||
|
||||
def test_base_search_mail_content_1(self):
|
||||
res = self.channel_obj.search([("message_content", "ilike", "xxxyyyzzz")])
|
||||
|
@ -20,6 +20,6 @@ class TestBaseSearchMailContent(TransactionCase):
|
|||
)
|
||||
self.assertIn(
|
||||
"message_content",
|
||||
res["models"]["mail.channel"],
|
||||
res["models"][self.channel_obj._name],
|
||||
"message_content field was not detected",
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue