Koray
Koray

Reputation: 91

How can I remove archive button from tree view?

I do not want my user group to archive records when my user group has the create and write rights. For kanban view "archivable='false'" is an option but for the list view, this does not exist. How can I remove or don't show this button for that user group?

Upvotes: 1

Views: 2055

Answers (3)

Koray
Koray

Reputation: 91

Add groups='your_module.your_group' to your active field.

This solved my problem.

Upvotes: 2

Adam Strauss
Adam Strauss

Reputation: 1999

You can use the group option in button menu like this

<button name="order_confirm" states="draft" string="Confirm Order" groups="xml id( group)"/>

This will show that particular button for specific group only..

Upvotes: 1

Dipen Shah
Dipen Shah

Reputation: 2444

You can dynamically hide for the specific user with fields_view_get method.

@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, 
    submenu=False):
res = super(Classname, self).fields_view_get(
    view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
if view_type == 'tree' and self.user_has_groups('Your Group') and Other Condition:
    doc = etree.XML(res['arch'])
    for node in doc.xpath("//your button"):
        node.set('modifiers', json.dumps({'invisible': 1}))
    res['arch'] = etree.tostring(doc, encoding='unicode')
return res

Thanks

Upvotes: 1

Related Questions