ODOO
views
To explain this let us say we have the student object in which we have the level field which is a selection field as bellow
level = fields.Selection([('first','First'),('second','Second'),('third','Third')], string="Level")
and we want to put each level's students in single view , so we can do it as bellow
for each level we have to
- add the action record
<record model="ir.actions.act_window" id="first_level_student_action">
<field name="name">The First Level Students</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">student.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('level','=','first')]</field>
<field name="context">{}</field>
<field name="search_view_id" ref="module_name.view_student_search" />
</record>
<field name="name">The First Level Students</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">student.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('level','=','first')]</field>
<field name="context">{}</field>
<field name="search_view_id" ref="module_name.view_student_search" />
</record>
// this will only get the students of the first level
- add the form view
<record model="ir.actions.act_window.view" id="first_level_student_action_form">
<field name="act_window_id" ref="first_level_student_action" />
<field name="sequence" eval="10" />
<field name="view_mode">form</field>
<field name="view_id" ref="module_name.view_first_level_student_form" />
</record>
<field name="act_window_id" ref="first_level_student_action" />
<field name="sequence" eval="10" />
<field name="view_mode">form</field>
<field name="view_id" ref="module_name.view_first_level_student_form" />
</record>
- add the tree view
<record model="ir.actions.act_window.view" id="first_level_student_action_tree">
<field name="act_window_id" ref="first_level_student_action" />
<field name="sequence" eval="20" />
<field name="view_mode">form</field>
<field name="view_id" ref="module_name.view_first_level_student_tree" />
</record>
<field name="act_window_id" ref="first_level_student_action" />
<field name="sequence" eval="20" />
<field name="view_mode">form</field>
<field name="view_id" ref="module_name.view_first_level_student_tree" />
</record>
- add the menuitem
<menuitem id="first_level_menu" sequence="10" parent="module_name.root_menu"
action="first_level_student_action" />
action="first_level_student_action" />
No comments:
Post a Comment