Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
2300 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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>

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
zář 22
2569
1
srp 22
2582
0
dub 22
3485
1
led 22
4418
2
říj 16
3285