OSV method's return statement

☆樱花仙子☆ 提交于 2019-12-19 08:28:45

问题


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:


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.



来源:https://stackoverflow.com/questions/10671025/osv-methods-return-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!