Skip to content Skip to sidebar Skip to footer

Odoo/openerp: Hiding Create Button From Treeview

I have a situation here. I am using OpenERP 7. I am trying to hide Create button from tree view of my products. this can be done using

Solution 1:

Are the views your accessing the same or are they different ?

If they are different, I believe the proper way to implement your requirement is to override the relevant view with the

create="false"

property you mentioned.

From the technical memento:

View Inheritance

Existing views should be modifying through inherited views, never directly. An inherited view references its parent view using the inherit_id field, and may add or modify existing elements in the view by referencing them through XPath expressions, and specifying the appropriate position.

Hope this helps.


Solution 2:

I successfully solved the very same issue by using field_view_get:

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    res = models.Model.fields_view_get(self, cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
    default_type = context.get('default_type', False)
    can_create = default_type != 'out_customer_production'
    update = not can_create and view_type in ['form', 'tree']
    if update:
        doc = etree.XML(res['arch'])
        if not can_create:
            for t in doc.xpath("//"+view_type):
                t.attrib['create'] = 'false'
        res['arch'] = etree.tostring(doc)

    return res

(I left tree and form view without the create attribute)


Solution 3:

Don't know how to do it in python + xml either, i would stick with javascript extension, that gets data from context or from fields and disable and hide button depending on that data.


Post a Comment for "Odoo/openerp: Hiding Create Button From Treeview"