Skip to Content
Menu
This question has been flagged
3 Replies
2288 Views

Hi, I am new to odoo development following this tutorial in development (sry: couldn't attach the link.

however, after adding menu items, it kinda works, but the fields in the form is all over the place and it is not structured at all. Where did i do wrong.

Avatar
Discard
Best Answer

Hi,
That might be because you didn't follow the proper structure for the View.

Group appropriate fields and try giving widgets for Many2many fields. Also use notebook pages for Many2one fields. 

Also, if you are adding chatter, add it after the form tag. Following these might give you a structured form

Regards

Avatar
Discard
Author Best Answer

I am really really new to this, and was following the tutorials with these codes

in views.xml

 id="test_model_action" model="ir.actions.act_window">
     name="name">Test action
     name="res_model">test.model
     name="view_mode">tree,form
in menus.xml
 id="test_menu_root" name="Test">
     id="test_first_level_menu" name="First Level">
         id="test_model_menu_action" action="test_model_action"/>
    
The fields are scattered across the form. It does not appear as shown in the goal section.


Avatar
Discard

Create form view for this model as like follows
<record id="test_modle_form_view" model="ir.ui.view">
<field name="name">test.model.form</field>
<field name="model">test.modle</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="test_field_1"/>
<field name="test_field_2"/>
</group>
</group>
</sheet>
</form>
</field>
</record>

Best Answer

Hi 

You can add the fields inside the form inside the tag.

Try with this code snippet for a form view

<record id="school_class_form_view" model="ir.ui.view">
   <field name="name">school.student.form</field>
   <field name="model">school.student</field>
   <field name="arch" type="xml">
       <form string="Student">
           <header>
                  <button name="action_confirm" type="object"
                           string="Confirm"
                           states="draft"/>
                   <field name="state" widget="statusbar"/>
           </header>
           <sheet>
               <group>
                   <group>
                       <field name="admn_code"/>
                       <field name="name"/>
                       <field name="address"/>
                       <field name="class_id"/>
                       <field name="division"/>
                   </group>
                   <group>
                       <field name="dob"/>
                       <field name="age"/>
                       <field name="admn_date"/>
                       <field name="officer_id"/>
                   </group>
               </group>
           </sheet>
           <div class="oe_chatter">
               <field name="message_follower_ids"/>
               <field name="activity_ids"/>
               <field name="message_ids"/>
           </div>
       </form>
   </field>
</record>


https://www.cybrosys.com/blog/basic-views-in-odoo-15#:~:text=Form%20View%20is%20used%20to,both%20structural%20and%20semantic%20components.

https://www.odoo.com/documentation/16.0/developer/reference/backend/views.html


Hope this Helps

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 22
2552
1
Aug 22
2575
0
Apr 22
3476
1
Jan 22
4411
2
Oct 16
3278