How to Return a View Using Python

 

How to Return a View Using Python


   @api.multi
    def invoice_view_form(self):
        ir_model = self.env['ir.model.data']
        tree_view_id = ir_model.get_object_reference('account','invoice_tree')[1]
        form_view_id = ir_model.get_object_reference('account','invoice_form')[1]
        inv_ids = self.env['account.invoice'].search([('sale_id','=',self.id)])
       

        return {
            'name': "Invoices",
            'view_type': 'form',
            'domain' : [('sale_id','=',self.id)],
            'view_mode': 'tree,form',
            'view_id': wiz_view_id,
            'views' : [(wiz_view_id,'tree'),(form_view_id,'form')],
            'res_model': 'account.invoice',
            'context': "{'type':'out_invoice'}",
            'type': 'ir.actions.act_window',
            'target': 'current',
        }


  • 'name': "Invoices"  - Name of the view
  • 'view_type': 'form'  - 
  • 'views' : [(wiz_view_id,'tree'),(form_view_id,'form')] This this important thing so here you need to pass view id and view mode.


Comments

Popular posts from this blog

Uninstall ODOO module using terminal

How to Delete Menuitem-Odoo