[MIG] base_search_mail_content: Migration to 16.0

pull/1164/head
Andrea 2023-06-12 12:05:23 +02:00
parent 907fc458d4
commit e5dec4b2f5
3 changed files with 6 additions and 13 deletions

View File

@ -6,7 +6,7 @@
{
"name": "Base Search Mail Content",
"version": "15.0.1.0.1",
"version": "16.0.1.0.1",
"author": "ForgeFlow, SerpentCS, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"category": "Social",

View File

@ -6,7 +6,7 @@
from lxml import etree
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.osv import expression
@ -38,21 +38,14 @@ class MailThread(models.AbstractModel):
self.message_content = False
@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
def get_view(self, view_id=None, view_type="form", **options):
"""
Override to add message_content field in all the objects
that inherits mail.thread
"""
res = super(MailThread, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
res = super().get_view(view_id=view_id, view_type=view_type, options=options)
if view_type == "search" and self._fields.get("message_content"):
doc = etree.XML(res["arch"])
res["fields"].update(
{"message_content": {"type": "char", "string": _("Message Content")}}
)
for node in doc.xpath("/search/field[last()]"):
# Add message_content in search view
elem = etree.Element("field", {"name": "message_content"})

View File

@ -14,12 +14,12 @@ class TestBaseSearchMailContent(TransactionCase):
self.assertFalse(res, "You have a channel with xxxyyyzzz :O")
def test_base_search_mail_content_2(self):
res = self.channel_obj.load_views(
res = self.channel_obj.get_views(
[[False, "search"]],
{"load_fields": False, "load_filters": True, "toolbar": True},
)
self.assertIn(
"message_content",
res["fields_views"]["search"]["fields"],
res["models"]["mail.channel"],
"message_content field was not detected",
)