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.
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
2
Replies
2326
Views
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
Thanks bro. Its Its working now!!
Thanks bro. Its working now!!
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