Skip to Content
Menu
This question has been flagged
2 Replies
2326 Views

I need to hide create button when tree view is called from the main menu and show create button when a button calls the same tree view. Please help.

Avatar
Discard
Best Answer
Hello Darshil
you can pass context from button and then based on that context you can hide or show create button with fields_view_get method.
Example:
@api.model
def fields_view_get(self, view_id=None, view_type='form',
toolbar=False, submenu=False):
ret_val = super(TreatmentExtended, self).fields_view_get(
view_id=view_id, view_type=view_type,
toolbar=toolbar, submenu=submenu)
if self._context.get('your context') and view_type == 'form' and view_id='your view id':
doc = etree.XML(ret_val['arch'])
for node in doc.xpath("//form"):
node.set('create','true')
ret_val['arch'] = etree.tostring(doc)
return ret_val
Avatar
Discard
Author

Thanks bro. Its Its working now!!

Author Best Answer

Thanks bro. Its working now!!

Avatar
Discard