4
votes

In OpenERP, an OSV object can return something which can open a new view or activate an action. For instance, sale.order has manual_invoice method which returns the following:

    return {
        'name': _('Customer Invoices'),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': [res_id],
        'res_model': 'account.invoice',
        'context': "{'type':'out_invoice'}",
        'type': 'ir.actions.act_window',
        'nodestroy': True,
        'target': 'current',
        'res_id': inv_ids and inv_ids[0] or False,
    }

and it opens an invoice form view in the same window.

I've seen 'view_id': [res_id], being changed to 'views': [(id2, 'form')], and other parts also modified, and it still works.

So what I don't understand is how does this mechanism works. What determines which values in a return dict should be included? How can I know which ones are mandatory and which are not?

Many thanks!

1

1 Answers

5
votes

The returned dictionary is interpreted as an action (ir.actions.act_window model), such as the ones found on XML views. The documentation is available in the Technical Memento and in the official docs.