Hi,
I would like to hide the WhatsApp button, which is located next to 'add note' in the contact form, but only for certain groups. Has anyone ever tried to do this?
thank you
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I would like to hide the WhatsApp button, which is located next to 'add note' in the contact form, but only for certain groups. Has anyone ever tried to do this?
thank you
Hi,
Yes, you can prevent certain users from seeing the WhatsApp button in the chatter, but not via a simple checkbox. In Odoo, that button is shown based on user groups and access rights.
The usual way to handle this is to restrict the WhatsApp feature to specific groups. You can do this by checking which group is linked to the WhatsApp integration and then removing that group from users who shouldn’t see the button. If the button is added through a view, you can also hide it by inheriting the chatter view and adding a group condition so it only appears for allowed users.
In short, control it through user groups or view inheritance, depending on how the WhatsApp feature is implemented in your database.
Hope it helps
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
WhatsApp Button location[Odoo 18]:
<xpath expr="//*[contains(@class, 'o-mail-Chatter-activity')]" position="before">
<button t-if="state.thread.canSendWhatsapp"
class="btn btn-secondary text-nowrap me-1"
t-att-class="{'my-2': !props.compactHeight }"
data-hotkey="shift+w"
t-on-click="sendWhatsapp"
>
<span>WhatsApp</span>
</button>
</xpath>
You need to manage user condition from JS side.
I already try, via javascript but without success.
Have you any example I can follow?
I will try and let you know.
Hello
These 2 methods are helpful to understand the WhatsApp Button logic and also you can add custom logic inside them.
@api.model
def _can_use_whatsapp(self, model_name):
if not self.has_access('read'):
return False
return self.env.user.has_group('whatsapp.group_whatsapp_admin') or \
len(self._find_default_for_model(model_name)) > 0
def _thread_to_store(self, store: Store, /, *, request_list=None, **kwargs):
super()._thread_to_store(store, request_list=request_list, **kwargs)
if request_list:
store.add(
self,
{"canSendWhatsapp": self.env["whatsapp.template"]._can_use_whatsapp(self._name)},
as_thread=True,
)