我在Odoo 10中创建了一个新模型.该模型通过菜单项访问,该菜单项启动树视图.
树视图是可编辑的,但我希望能够启动用户想要编辑的特定记录用户正在编辑的表单视图.
是否有任何选项可以在树视图中放置一个按钮来启动表单视图?有人可以突出显示所需的步骤或指向类似的代码示例吗?
谢谢,
使用按钮:在树视图中:
<tree editable="top">
...
...
<button name="open_record" type="object" class="oe_highlight"/>
</tree>
Run Code Online (Sandbox Code Playgroud)
在你的模型中:
@api.multi
def open_record(self):
# first you need to get the id of your record
# you didn't specify what you want to edit exactly
rec_id = self.someMany2oneField.id
# then if you have more than one form view then specify the form id
form_id = self.env.ref('module_name.form_xml_id')
# then open the form
return {
'type': 'ir.actions.act_window',
'name': 'title',
'res_model': 'your.model',
'res_id': rec_id.id,
'view_type': 'form',
'view_mode': 'form',
'view_id': form_id.id,
'context': {},
# if you want to open the form in edit mode direclty
'flags': {'initial_mode': 'edit'},
'target': 'current',
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4057 次 |
| 最近记录: |