From b879bcb78186b57c9c8a1beb5a5e87eb078f5fe1 Mon Sep 17 00:00:00 2001 From: darshan-serpent Date: Mon, 2 Jan 2017 16:16:39 +0530 Subject: [PATCH] [FIX] field type --- mail_message_name_search/models/mail_message.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mail_message_name_search/models/mail_message.py b/mail_message_name_search/models/mail_message.py index 0c7f6a47..0250e427 100644 --- a/mail_message_name_search/models/mail_message.py +++ b/mail_message_name_search/models/mail_message.py @@ -15,20 +15,26 @@ _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): + """ + Override to add message_ids field in all the objects + that inherits mail.thread + """ # 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]"): + # Add message_ids in search view elem = etree.Element('field', { 'name': 'message_ids', 'domain': "[('model','=', %s)]" % self._model }) node.addnext(elem) + # Register message_ids in fields res['fields'].update({ 'message_ids': { - 'type': 'many2one', + 'type': 'one2many', 'relation': 'mail.message', 'string': 'Messages', } @@ -46,6 +52,7 @@ class MailMessage(models.Model): @api.model def name_search(self, name='', args=None, operator='ilike', limit=100): + """Override to search on multiple fields""" args = args or [] domain = ['|', '|', ('record_name', operator, name), ('subject', operator, name), ('body', operator, name)]