This question has been flagged
1 Reply
4413 Views

Hi,

Im trying to add an history button for a records in form view, just for context, the history of the record it does from a copy of the record before applying the changes. So, when I click the button in the form view, just have a tree form who can't be browsed (no links), Is there a way to open a tree view from a button and then navigate through the records in that tree view in a popup from the first record?

This is the code I'm using for the popup window at this moment, tree-non-navigable 

based on code from product_margin.py

@api.multi
def action_open_cache(self): 

    self.ensure_one() 
    context = dict(self.env.context or {})
 
    def ref(module, xml_id): 
        proxy = self.env['ir.model.data'] 
        return proxy.get_object_reference(module, xml_id) 

    model, form_view_id = ref(u'integration', u'integration_templates_cache_form_view') 
    model, tree_view_id = ref(u'integration', u'integration_templates_cache_tree_view') 

    views = [(tree_view_id, 'tree'), 
        (form_view_id, 'form'),] 

    return {
            'name': u'History', 
      'context': context, 
     'view_type': 'tree', 
     'view_mode': 'tree,form', 
     'res_model': 'integration.templates.cache',
       'type': 'ir.actions.act_window', 
     'views': views, 
     'domain':[('form_id','=', self.id)], 
     'target': 'new' 
 
    }
Avatar
Discard
Best Answer

You should use view_type = form

Ex:

'view_type': 'form',  

Avatar
Discard
Author

I've tryed it before but it opens the record in edit mode, i'm using your answer and i've created a new view with read_only fields to workaround that and replaced footer buttons, thanks