Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
To hide the Log Note button in the Chatter for the CRM view (or any other model) in Odoo, you are using an XML modification to override the mail.Chatter template. Here's how to ensure your approach works correctly:
1. Review Your Current Code
Your current XML code:
<templates xml:space="preserve"> <t t-name="Chatter" t-inherit="mail.Chatter" t-inherit-mode="primary"> <xpath expr="//button[@class='o-mail-Chatter-logNote']" position="attributes"> <attribute name="invisible">1</attribute> </xpath> </t> </templates>
Checklist for your code:
- Correct Template Name: Ensure mail.Chatter is the correct template to inherit. This is the main template for the Chatter component in Odoo.
- XPath Accuracy: The XPath targets the Log Note button using the class o-mail-Chatter-logNote. Ensure the button has this class.
- Inherit Mode: You are using t-inherit-mode="primary", which is correct for adding or overriding content in the parent template.
2. Common Issues
- Incorrect Class: If the button class is dynamic or incorrect, the XPath will not match the element. Inspect the Chatter DOM in the browser (Developer Tools > Inspect) to verify the class.
- Incorrect Template Loading: Ensure the XML file is loaded in the module's __manifest__.py file.
- Incorrect Field Usage: The invisible attribute might not work as expected here. Use t-attributes to dynamically set visibility.
3. Fix the Code
If invisible doesn’t work, use t-attributes to hide the button dynamically:
<templates xml:space="preserve"> <t t-name="Chatter" t-inherit="mail.Chatter" t-inherit-mode="primary"> <xpath expr="//button[@class='o-mail-Chatter-logNote']" position="attributes"> <attribute name="t-attributes">{'class': 'd-none'}</attribute> </xpath> </t> </templates>
Here, the d-none class is added, which hides the button using Bootstrap's utility class.
4. Ensure XML File is Loaded
In the __manifest__.py file of your module, include the XML file:
'data': [ 'view/chatter_inherit.xml', ],
5. Test the Changes
- Restart your Odoo server:
./odoo-bin -c odoo.conf
- Upgrade your module:
./odoo-bin -u your_module_name
- Check the CRM view and ensure the Log Note button is hidden.
6. Debugging Tips
- Inspect with Developer Tools: Ensure the Log Note button exists and the class matches your XPath.
- Check Logs: Look for errors in the Odoo logs (odoo.log) if the changes don’t take effect.
- Test XPath Separately: Use a broader XPath to ensure the targeting works:
<xpath expr="//button" position="attributes"> <attribute name="t-attributes">{'class': 'd-none'}</attribute> </xpath>
By following these steps, you should be able to successfully hide the Log Note button in the Chatter for the CRM view. Let me know if you need further assistance!
Can you provide the full code?
Hi you can inherit a CRM XML view and add inside CSS value
.o_ChatterTopbar_buttonLogNote{
display: none;
}
Is it possible to keep it on based on state, like the button should get invisible if project.state is done
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Oct 24
|
871 | ||
|
0
Sep 24
|
796 | ||
|
0
Sep 24
|
730 | ||
|
0
Oct 24
|
871 | ||
|
2
Sep 24
|
1083 |