Search code examples
odooodoo-10odoo-11odoo-12

ir.actions.act_window displays a list of purchase orders


I want to allow user to press a button and display a list of Purchase Orders (specifically the IDs included in pos.ids).

If I include this code in the action controller of the button I get the list:

            return {
                    'name': 'Purchase Order List',
                    'view_type': 'form',
                    'view_mode': 'tree',
                    'view_id': self.env.ref('purchase.purchase_order_tree').id,
                    'res_model': 'purchase.order',
                    'domain':[('id','in',pos.ids)],
                    'type': 'ir.actions.act_window',
                    'target': 'current',
            }

However, in that list I can not click on the specific Purchase Order and open the form view. Why? What shall be done to achieve that?


Solution

  • You specified the view_mode as tree only, If you want to see the form view of the record also have to specify the form view.And you don't have to specify the view_id in this case.

    Change your code like this and try.

      return {
                'name': 'Purchase Order List',
                'view_type': 'form',
                'view_mode': 'tree,form',  # Changed
                'res_model': 'purchase.order',
                'domain':[('id','in',pos.ids)],
                'type': 'ir.actions.act_window',
                'target': 'current',
            }