Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1314 Lượt xem

I'm working on customizing the mail.Chatter template in Odoo 17 to hide specific buttons, such as "Send Message" and "Log Note," in certain scenarios. I've tried using XML inheritance and XPath to modify the mail.Chatter template in my module, as follows:


<t t-name="akf.child.mail.Chatter" t-inherit="mail.Chatter">

    <xpath expr="//button[contains(@class, 'o-mail-Chatter-sendMessage')]" position="attributes">

        <attribute name="t-if">false</attribute>

    </xpath>

</t>


However, when I load my module, I get an error indicating that the template name is missing or that the inheritance is incorrect.

Has anyone successfully customized mail.Chatter in Odoo 17 to hide elements like these buttons? What would be the recommended approach, and is there a better way to control the visibility of buttons in mail.Chatter?


Ảnh đại diện
Huỷ bỏ

Enhance your Odoo mail chatter experience by dynamically controlling the visibility of key buttons based on user preferences.
With this app, administrators can configure visibility settings for the most commonly used buttons in the chatter interface, such as "Send Message", "Log Note", "Activities", and more. Tailor the interface to individual users or specific models, ensuring a streamlined, role-based user experience.

https://apps.odoo.com/apps/modules/17.0/mh_hide_chatter_view_buttons

Câu trả lời hay nhất

espere

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try this:


<t t-inherit="mail.Chatter" t-inherit-mode="extension">

<xpath expr="//button[hasclass('o-mail-Chatter-sendMessage')]"

position="replace">

<t t-if="">// Add your condition

<button t-if="props.hasMessageList"

class="o-mail-Chatter-sendMessage btn text-nowrap me-1"

t-att-class="{

'btn-primary': state.composerType !== 'note',

'btn-secondary': state.composerType === 'note',

'active': state.composerType === 'message',

'my-2': !props.compactHeight

}"

t-att-disabled="!state.thread.hasWriteAccess and !(state.thread.hasReadAccess and state.thread.canPostOnReadonly) and props.threadId"

data-hotkey="m"

t-on-click="() => this.toggleComposer('message')">

Send message

</button>

</t>

</xpath>


Hope it helps

Ảnh đại diện
Huỷ bỏ