Openerp specifies view_id for both form and tree views.

Source: Internet
Author: User
Openerp specifies view_id for both form and tree views.

This article describes how to use view_id to specify the form and tree views for the same object (inherited by the same name) in openerp. As this is not mentioned in the views and Events section in the official documentation, but it will be used in actual projects, so record and share it here!

 

As mentioned in the official document, we may specify a view instead of the default one in two cases:

  • An object has several form or tree views.
  • You want to use a relational field (such as o2m) to change the form or Tree View.

The document introducesPriority Field:

In the view definition, we can use the priority field. Its default value is 16. by default, openerp uses the tree view with the highest priority (that is, the smallest number) to display a model.

OK. If you are new to openerp, it seems to be able to solve many problems at first glance, but the situation is not certain, because there is a line of bold words written:

It will always use the second one, because it has a higher priority! Unless you tell it to use the first one!

What is "unless you tell it to use the first (View )"? Can't I understand that the first one has been abandoned?

Okay. Let's take a look at how to specify a view for each action? Use fields in IR. Actions. act_windowView_idThe ref value is the ID of the specified view. Of course, if you want to specify a view defined in another module, remember to add the module name (module. view_id ).

For the function of this field, it looks good to specify the ID directly without having to arrange any priority. Besides, the document does not introduce how to use low-priority views. So for a model with the same name integrated, since there are various views (Form/tree/Kanban etc.), and we want to change the form and tree views during the customization process, what should we do? In view_mode, we specify that the tree is in the front. Why does it not work?

Google found the answer:

There is a model named IR. Actions. act_hangzhou lateral view, which we can use to solve the problem perfectly. We define a record that contains only four fields:

  • <Field name = "sequence" EVAL = "1"/>
  • <Field name = "view_mode"> form </field>
  • <Field name = "view_id" ref = "module. view_id"/>
  • <Field name = "act_window_id" ref = "Your act_window ID"/>

That's all!

(End)

This entry was published on March 13, January 14, 2014. It belongs to the openerp development category and is labeled with the OE project. The author is Tony.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.