Odoo,openerp Chinese web/2014-07-16
The text is about the same object in OpenERP (inherited by the same name) using view_id to specify the form and tree view method, because the official document in the section and events that is not mentioned, but the actual project will be used, so record and share!
As mentioned in the official documentation, there are two situations where we might specify a view instead of the default one:
- An object has several form or tree views
- Want to change the form or tree view with a relationship field (for example, o2m)
The following document describes the Priority field:
In the definition of the view we can use the Priority field, whose default value is 16. By default, OpenERP displays a model with the tree view with the highest priority (that is, the smallest number).
OK, if it is just contact OpenERP, at first glance seems to solve a lot of problems, but the situation is not necessarily, because there is a line of bold words to write:
It'll always use the second one, because it have a higher priority! Unless your it to use the first one!
What do you mean "unless you tell it to use the first (view)"? Can't I understand that the first one was abandoned?
OK, let's see how do I specify view for each action? The value of the field view_id,ref used in Ir.actions.act_window is the ID of the specified view. Of course, if you want to specify a view that is defined in another module, remember to add the module name (that is, module.view_id).
For the function of this field, it seems to be good to listen, directly specify the ID, rather than to prioritize, not to mention the document does not describe the low-priority view how to use. So for a model with the same name integration, because there are already various views (Form/tree/kanban etc), and we want to change the form and tree view during the customization process, what should I do? And why doesn't it work when we specify the tree in the View_mode?
Found the answer through Google:
There is a model called Ir.actions.act_window.view, we can use it to solve the problem perfectly. We define a record that contains only 4 field:
- <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
OPENERP Specifies the view_id method for both form and tree views