gpt4 book ai didi

奥杜 10 : Open a form view in an editable tree view

转载 作者:行者123 更新时间:2023-12-02 12:08:58 24 4
gpt4 key购买 nike

我正在 Odoo 10 中创建一个新模型。该模型可通过启动 TreeView 的菜单项访问。

TreeView 是可编辑的,但如果用户愿意,我希望能够为用户正在编辑的特定记录启动表单 View 。

是否有任何选项可以在 TreeView 中放置一个按钮来启动表单 View 或其他东西?有人可以突出显示所需的步骤或指出类似的代码示例吗?

谢谢

最佳答案

使用按钮: 在 TreeView 中:

 <tree editable="top">
...
...
<button name="open_record" type="object" class="oe_highlight"/>
</tree>

在你的模型中:

  @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',
}

关于奥杜 10 : Open a form view in an editable tree view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45316649/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com