Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to add a tree view in openerp 7?

By
sneha antony
on 3/3/14, 5:34 AM 4,275 views

I had developed a simple module student_info in my openerp 7.I have a form view in which I want to create a tree view having two columns Date and Status.The screen shot of view attachedScreenshot-1.png I want to have a grid with two columns Date and Status under the tab heading Student Status.My present xml file and py file are attached.

student_info.py

  from openerp.osv import osv, fields

class student_student(osv.osv):

_name = 'student.student'

_columns = {
'name':fields.char('Student Name',size=16,required = True,translate = True),
'age':fields.integer('Age',required = True),
'percent':fields.float('Percentage',help = 'This field will add average marks of students out of 100'),
'gender':fields.selection([('male','Male'),('female','Female')],'Gender'),
'active':fields.boolean('Active'),
'notes':fields.text('Details'),
}

_defaults = { 'name':'Atul',
      'active':True,
}
student_student()

student_info_view.xml

    <?xml version="1.0" encoding="utf-8"?>
 <openerp>
  <data>


    <!--Student search view-->
    <record model="ir.ui.view" id="student_search">
        <field name="name">student.search</field>
        <field name="model">student.student</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
          <search string = "student information search">
            <field name="name" string = "Student Name"/>
            <field name="gender" string = "Gender"/>  
            <field name="age" string = "Age"/>
           </search>
        </field>
    </record>



      <!--Student tree View-->
      <record id="student_student_tree" model="ir.ui.view">
        <field name="name">student.result.tree</field>
        <field name="model">student.student</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
          <tree string="Student_result">  
            <field name="name"/>  
            <field name="age"/>
        <field name="percent"/> 
            <field name="gender"/>  
            <field name="active"/>
            </tree>
        </field>
    </record>


      <!--Student Form View-->
        <record id="student_student_form" model="ir.ui.view">
            <field name="name">student.result.form</field>
            <field name="model">student.student</field>
          <!--<field name="type">form</field>-->
            <field name="arch" type="xml">
              <form string="Student_result" version="7.0">  
              <sheet>
               <group>
                <group>
                 <field name="name" />
                 <field name="age" />
                 <field name="percent" />
                 <field name="gender" />
                 <field name="active" />
                 <field name="notes" /> 
              </group>
                </group>
            </sheet>
            </form>
            </field>
        </record>

      <!--Student Action-->
        <record id="action_student_student" model="ir.actions.act_window">
            <field name='name'>Student Information</field>
            <field name='res_model'>student.student</field>
            <field name='view_type'>form</field>
            <field name='view_mode'>tree,form</field>
        </record>

       <!--Student Menu-->
         <menuitem id="student_parent" name="student"/>
         <menuitem id="menu_student_parent" name="Student Management" parent="student_parent"></menuitem>
         <menuitem action="action_student_student" id="menu_student_student" parent="menu_student_parent"      string="Result"/>
             </data>
         </openerp>

What are the code changes to be made in the present files.I am very new to openerp and tried for a long time yet the syntax for treee view was not found.So any help is greatly appreciated.

1

Jagdish Panchal

--Jagdish Panchal--
2674
| 5 3 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 3/3/14, 9:56 AM

Hi Try this

  <!--Student tree View-->
    <record id="student_student_tree" model="ir.ui.view">
        <field name="name">student.result.tree</field>
        <field name="model">student.student</field>
        <field name="arch" type="xml">
            <tree string="Student_result">  
                <field name="name"/>  
                <field name="age"/>
                <field name="percent"/> 
                <field name="gender"/>  
                <field name="active"/>
            </tree>
        </field>
    </record>

where to write this coding?Isnt there any change in .py file?

sneha antony
on 3/4/14, 12:32 AM

Add this code in .xml file

Jagdish Panchal
on 3/4/14, 1:55 AM

should I replace the present code for student tree view or else paste as another code?

sneha antony
on 3/4/14, 3:37 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/3/14, 5:34 AM
Seen: 4275 times
Last updated: 3/16/15, 8:10 AM