在可编辑树视图中打开表单视图

在可编辑树视图中打开表单视图

本文介绍了Odoo 10:在可编辑树视图中打开表单视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Odoo 10中创建一个新模型.可通过启动树状视图的菜单项访问该模型.

I am creating a new model in Odoo 10.This model is accessed through a menu item which launches tree view.

树视图是可编辑的,但是我希望能够为用户正在编辑的特定记录启动表单视图.

Tree view is editable but I would like to be able to launch form view for the specific record user is editing if user wants to.

是否可以在树形视图中放置一个按钮以启动表单视图?有人可以突出显示所需的步骤或指向类似的代码示例吗?

Is there any option to either put a button in the tree view to launch the form view or something? Could someone highlight the steps required or point to a similar code example?

谢谢

推荐答案

使用按钮: 在树状视图中:

using a buttons : in tree view:

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

这篇关于Odoo 10:在可编辑树视图中打开表单视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:11