0

In Odoo, I can open a record in form view by using a button to trigger an action on the data model:

@openerp.api.multi
def open_record_in_form_view(self):
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'model.name',
        'views': ((False, 'form'), (False, 'tree')),
        'res_id': RECORD_ID,
        'domain': [('field', '=', 'value')],
    }

The record opens correctly, except that the pager is disabled. The curious bit is that when I toggle from form view to list view, the correct set of records is shown (as per the specified domain), and then when I toggle back from list view to form view, the pager is enabled, and I can page through the records in the domain.

How do I enable the pager when first opening form view? I want to page through a set of records a in domain, but in form view, not in list view view.

Monica For CEO
  • 499
  • 6
  • 20
  • Have you tried adding view_mode and view_type? ... 'view_mode': 'tree', 'view_type': 'tree', ... – Ivica Nov 07 '17 at 12:22
  • Thanks for the suggestion! Yes, I tried setting `view_mode` and `view_type`, and I also tried setting `views`. As I understand it, Odoo initializes the value for the `views` settings from the `view_mode` and `view_type` settings. You can read a (very) little bit about that here: https://www.odoo.com/documentation/8.0/reference/actions.html Still at a loss for how to do this. – Monica For CEO Nov 07 '17 at 22:25

1 Answers1

0
def open_record_in_form_view(self):
return {
    'name': 'name of Action',
    'type': 'ir.actions.act_window',
    'res_model': 'model.name',
    'view_mode': 'tree,form',
    'domain': [('field', '=', 'value')],
}

you need to add 'name' and 'view_mode' fields ...

omar ahmed
  • 635
  • 5
  • 19