简体   繁体   中英

Odoo 9 How to edit chatter opportunity notes view

I spent plenty of hours, trying to solve my issue, I want to edit view of note in chatter in odoo crm.lead, because I want to add subtype of note (email or note or task etc.) after author of note, I know how to get value but I have no idea what I need to edit to change message view in chatter, everything what I know is this line from view which is declaring whole chatter:

<field name="message_ids" widget="mail_thread"/>

so please tell me what and where I need to change to add subtype to note in chatter:

那就是我要改变的

Ok guys, as always, I must to do everything by myself, so I will post what I found maybe I will help someone:

You need to go to static > src > xml > thread.xml there you must to search in website source what is this thing you want to edit:

在此处输入图片说明

Then search for o_thread_message_core in xml file

When you found it you need to search things from our line for example res.partner or date then you will get where you can add some things, I added this line to code:

<t t-if="message.model == 'crm.lead' &amp;&amp; (message.is_note)">
                    Type: <t t-esc="message.subtype_id[1]"/>
                </t>

After all, code of this line looks like that:

<div t-att-class="'o_thread_message_core' + (message.is_note ? ' o_mail_note' : '')">
            <p t-if="message.display_author" class="o_mail_info">
                <t t-if="message.is_note">
                    Note by
                </t>

                <strong t-if="message.mailto">
                    <a class="o_mail_mailto" t-attf-href="mailto:#{message.mailto}?subject=Re: #{message.subject}">
                        <t t-esc="message.mailto"/>
                    </a>
                </strong>
                <strong t-if="!message.mailto &amp;&amp; message.author_id[0]"
                        data-oe-model="res.partner" t-att-data-oe-id="message.author_redirect ? message.author_id[0] : ''"
                        t-attf-class="#{message.author_redirect ? 'o_mail_redirect' : ''}">
                    <t t-esc="message.displayed_author"/>
                </strong>
                <strong t-if="!message.mailto &amp;&amp; !message.author_id[0]">
                    <t t-esc="message.displayed_author"/>
                </strong>

                <small t-att-title="message.date">
                    - <t t-esc="message.hour"/>
                </small>


                <!-- VVV HERE I ADDED THIS VVV-->
                <t t-if="message.model == 'crm.lead' &amp;&amp; (message.is_note)">
                    Type: <t t-esc="message.subtype_id[1]"/>
                </t>
                <!-- ^^^ HERE I ADDED THIS ^^^-->




                <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>
                <t t-if="message.origin_id &amp;&amp; (message.origin_id !== options.channel_id)">
                    (from <a t-att-data-oe-id="message.origin_id" href="#">#<t t-esc="message.origin_name"/></a>)
                </t>
                <span>
                    <i t-if="options.display_stars &amp;&amp; !message.is_system_notification"
                        t-att-class="'fa fa-lg o_thread_message_star ' + (message.is_starred ? 'fa-star' : 'fa-star-o')"
                        t-att-data-message-id="message.id" title="Mark as Todo"/>
                   <i t-if="message.record_name &amp;&amp; message.model != 'mail.channel' &amp;&amp; options.display_reply_icon"
                       class="fa fa-reply o_thread_message_reply"
                       t-att-data-message-id="message.id" title="Reply"/>
                    <i t-if="message.is_needaction &amp;&amp; options.display_needactions"
                       class="fa fa-check o_thread_message_needaction"
                       t-att-data-message-id="message.id" title="Mark as Read"/>
                </span>

            </p>

But there is one more thing to do yet: Subtype wasn't default imported to message look data so you need to search for some typical variable which isn't normal in message information (for me it was subtype_description) and find the place where it is imported and declared.

I found it in static > src > js > chat_manager.js:

在此处输入图片说明

As you see I actually added line which is importing subtype_id from message info, after all I can use message.subtype_id in xml as value, I was searching for.

Finally in odoo message looks like that:

在此处输入图片说明

Next thing to do is to make custom module from this because everything what I did, I did on local odoo database, but it is quite easy, so this issue is solved, have a nice day ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM