Skip to Content
Menu
This question has been flagged

have created server action button in res.partner tree view but I want to show it only in the menu that I have created in purchase. If the menu is contact then button should be hidden.


I want to show that button here only:

But the button should be hidden here:

Any suggestions would be appreciated. Thanks

Avatar
Discard
Author Best Answer

Finally was able to achieve it by using fields_view_get method:

def fields_view_get(self, view_id=None, view_type='tree', toolbar=False,
submenu=False):
res = super(ResPartner, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)

if not self._context.get('validate', False):
approve_button_id = self.env.ref('bv_vendor_approval.action_bulk_approve_vendors').id or False
for button in res.get('toolbar', {}).get('action', []):
if approve_button_id and button['id'] == approve_button_id:
res['toolbar']['action'].remove(button)

  return res

Avatar
Discard

is it possible without fields_view_get ? if not then why?

Author

Yes, possible by using javascript.

That helped me, thank you

Related Posts Replies Views Activity
0
Jul 21
58
0
May 23
1845
1
Jan 23
6370
1
Dec 20
5962
0
Dec 20
2698