OSV方法的return语句 [英] OSV method's return statement
问题描述
在OpenERP中,OSV对象可以返回可以打开新视图或激活动作的内容.例如,sale.order
具有manual_invoice
方法,该方法返回以下内容:
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.
我已经看到'view_id': [res_id],
被更改为'views': [(id2, 'form')],
并且其他部分也被修改了,并且仍然有效.
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?
非常感谢!
推荐答案
返回的字典被解释为一种动作(ir.actions.act_window
模型),例如在XML视图中找到的动作.该文档可在技术备忘录和
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.
这篇关于OSV方法的return语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!