Odoo 9 如何编辑聊天机会注释视图

Odoo 9 How to edit chatter opportunity notes view

我花了很多时间来解决我的问题,我想在 odoo 的聊天中编辑笔记视图 crm.lead,因为我想添加笔记的子类型(电子邮件或笔记或任务等。 ) 在笔记的作者之后,我知道如何获得价值,但我不知道我需要编辑什么来更改聊天中的消息视图,我所知道的一切都是来自视图的这一行,它声明了整个聊天:

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

所以请告诉我我需要更改什么以及在哪里更改以添加要在聊天中注释的子类型:

好吧,一如既往,我必须自己做所有事情,所以我会post我发现的东西也许我会帮助别人:

你需要转到static > src > xml > thread.xml 在那里你必须在网站源中搜索你想要编辑的是什么:

然后在xml文件中搜索o_thread_message_core

当您找到它时,您需要从我们的行中搜索内容,例如 res.partner 或日期,然后您将找到可以添加一些内容的地方,我将这一行添加到代码中:

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

毕竟,这一行的代码是这样的:

<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>

但是还有一件事要做: 子类型未默认导入到消息外观数据中,因此您需要搜索一些在消息信息中不正常的典型变量(对我来说是 subtype_description)并找到它被导入和声明的位置。

我在 static > src > js > chat_manager.js:

找到了

如你所见,我实际上添加了从消息信息中导入 subtype_id 的行,毕竟我可以在 xml 中使用 message.subtype_id 作为值,我正在搜索。

最后在 odoo 中的消息看起来像这样:

接下来要做的是从中制作自定义模块,因为我所做的一切都是在本地 odoo 数据库上完成的,但这很容易,所以这个问题已解决,祝你有美好的一天 ;)