1
votes

I’ve been trying to modifying the Odoo discussions with no success.

This is what I’m trying to achieve:enter image description here

I add messages with the "New Message" button to an Odoo module (in class mro.order). The messages are showing up in the Discussions module: enter image description here

But I need the title to be like ‘MRO00049 – Foliemast gaat steeds in alarm’ instead of just MRO00049. So I need mro_order.name – mro_order.omschrijving in the title. How can I change this?

I've been looking for a few hours everywhere in the code of the MRO module and the mail module but don't know how to do it...

I already found the title is in /mail/static/src/xml/thread.xml:

<t t-if="message.model &amp;&amp; (message.model != 'mail.channel') &amp;&amp; options.display_document_link">
    on <a t-att-href="message.url" t-att-data-oe-model="message.model" t-att-data-oe-id="message.res_id"><t t-esc="message.record_name"/></a>
</t>
1

1 Answers

2
votes

I think you need to override the default name_get function on mro.order and return the name in your preferred format, as name_get() is used to fill default value for record_name on newly created mail.message records without this value, eg.:

from odoo import api, models


class MroOrder(models.Model):
    _inherit = 'mro.order'

    @api.multi
    def name_get(self):
        result = []
        for rec in self:
            result.append((rec.id, u'%s - %s' % (rec.name, rec.description)))
        return result

I am not familiar with mro.order object, so I have assumed that by omschrijving field name you have meant description.

Note that this change will apply only to newly created messages (no effect on old messages).