Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
2229 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor Mejor respuesta

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
Descartar

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>

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 22
2467
1
ago 22
2491
0
abr 22
3400
1
ene 22
4328
2
oct 16
3230