I created a new model called res.partner.link.category. Then, I created a button which opens a customized tree of that model. Here is the function called by the button and which returns the tree:
def open_history(self, cr, uid, ids, context=None):
rplc_obj = self.browse(cr, uid, ids[0], context=context)
data_obj = self.pool.get('ir.model.data')
tree_data_id = data_obj._get_id(cr, uid, 'res_partner_extended', 'res_partner_link_category_tree_view')
form_data_id = data_obj._get_id(cr, uid, 'res_partner_extended', 'res_partner_link_category_edit_form_view')
tree_view_id = False
form_view_id = False
if tree_data_id:
tree_view_id = data_obj.browse(cr, uid, tree_data_id, context=context).res_id
if form_data_id:
form_view_id = data_obj.browse(cr, uid, form_data_id, context=context).res_id
return {
'name': 'History of "%s"' % rplc_obj.link_category_id.name,
'view_type': 'form',
'view_mode': 'tree',
'view_id': False,
'views': [(tree_view_id, 'tree'), (form_view_id, 'form'),],
'res_model': 'res.partner.link.category',
'domain': '[("partner_id", "=", %d), ("link_category_id", "=", %d)]' % (rplc_obj.partner_id, rplc_obj.link_category_id.id),
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'flags': {'tree': {'action_buttons': True},
'form': {'action_buttons': True},}
}
And this is the XML of the tree which is being shown:
<record id="res_partner_link_category_tree_view" model="ir.ui.view">
<field name="name">res.partner.link.category.tree</field>
<field name="model">res.partner.link.category</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Link categories">
<field name="type"/>
<field name="date"/>
<field name="observations"/>
</tree>
</field>
</record>
Everything is OK, except for the lack of delete buttons in the tree. I need them, why can't I see them? Is there any option or flag (like action_buttons) which must be specified? How can I show them?
I'd say these buttons only appear when the tree is inside a form in edit mode.