Is there a way to hide the Import button in the tree view for specific groups / users?
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
6044
Views
Place the following code inside the model file:-
@api.model
def fields_view_get(self, view_id=None, view_type='form',
toolbar=False, submenu=False):
result = super(<<<Module Name>>>>, self).fields_view_get(
view_id=view_id, view_type=view_type,
toolbar=toolbar, submenu=submenu)
# Disabling the import button for users who are not in import group
if view_type == 'tree':
doc = etree.XML(result['arch'])
if not self.env.user.has_group('<<<group_id>>>'):
# When the user is not part of the import group
for node in doc.xpath("//tree"):
# Set the import to false
node.set('import', 'false')
result['arch'] = etree.tostring(doc)
return result
Based on the answer here - \https://www.odoo.com/forum/help-1/question/how-to-hide-create-button-in-tree-view-for-all-users-except-one-group-123564