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
<tree create="false" .....
but situation is like. i want to keep it when user opens the tree view directly from "Asset Management" Module. But hide it when i click on Reporting for treeview.
I tried to use context like this from reporting button's function:
context['prod1']='false'
ctx = dict(context)
print ctx['prod1']
return {
'type': 'ir.actions.act_window',
'res_model': 'product.product',
'view_type': 'form',
'view_mode': 'tree,form',
'target': 'current',
'context':ctx,
'create':False,
'domain':[('id','in',domain)]
}
and in treeview form I did:
<tree create="context.get('prod1',False)"
but I get this json related error:
ERROR : SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
this stuff is working with my button but not with my tree view. I tried adding 'create':False
in return too, but unable to do what I want to. What am I missing?
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:
Hope this helps.
I successfully solved the very same issue by using field_view_get:
(I left tree and form view without the create attribute)
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.