I want to hide the edit button from a form view for a specific user or group, I am able to do it using the access control list by removing the permission to write on the model but it is causing to restrict the write permissions from where which is not the case?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
3754
Views
The basic Odoo approach is not to hide an element for a user group, but the opposite - to show an element.
To that end you should just add the attribute 'groups' to the xml view. For example, to show the button only for Odoo admins:
<button name="do_some_stuff
type="object"
string="Do some stuff"
class="oe_stat_button"
icon="fa-line-chart"
groups="base.group_erp_manager"
/>
Otherwise, you would need to have the special field which would be calculated based on user groups, and apply the xml 'attrs property. E.g.:
<field name="your_property" invisible="1"/>
<!-- the field 'your_property' should be a computed field, which is calculated based on self.env.user groups -->
<button name="do_some_stuff
type="object"
string="Do some stuff"
class="oe_stat_button"
icon="fa-line-chart"
attrs="{'invisible': [('your_property', '=', True]}"
/>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Hi Azlan, did you find the answer about this?