Skip to Content
Menu
This question has been flagged
7 Replies
12277 Views

Custom module, object with a tree and a form view linked on menu. 

<odoo>
<record id = "adm_sessions_tree_view" model = "ir.ui.view">
<field name = "name">adm.session.tree</field>
<field name = "model">pos.adm</field>
<field name = "arch" type = "xml">
<tree string = "Session Adm" create = 'false'>
<field name = "day_local"/>
<field name = "pos_ref"/>
<field name = "day_static"/>
<field name = "day_margin"/>
<field name = "day_sold"/>
<field name = "day_costs"/>
<field name = "month_margin"/>
<field name = "month_sold"/>
<field name = "month_costs"/>
<field name = "avg_minutes"/>
</tree>
</field>
</record>

<record id = "adm_sessions_form_view" model = "ir.ui.view">
<field name = "name">adm.session.form</field>
<field name = "model">pos.adm</field>
<field name = "arch" type = "xml">
<form>
<sheet>
<group colspan='4'>
<field name = "day_local"/>
<field name = "pos_ref"/>
<field name = "day_static"/>
<field name = "day_margin"/>
<field name = "day_sold"/>
<field name = "day_costs"/>
<field name = "month_margin"/>
<field name = "month_sold"/>
<field name = "month_costs"/>
<field name = "avg_minutes"/>
</group>
</sheet>
</form>
</field>
</record>


<record id = "adm_sessions_tree_view2" model = "ir.actions.act_window">
<field name = "name">AdM sessions</field>
<field name = "type">ir.actions.act_window</field>
<field name = "res_model">pos.adm</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree, form</field>
<field name = "view_id" ref= "adm_sessions_form_view"/>
</record>


<record id = "adm_sessions_tree_view3" model = "ir.actions.act_window">
<field name = "name">AdM sessions</field>
<field name = "type">ir.actions.act_window</field>
<field name = "res_model">pos.adm</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree, form</field>
<field name = "view_id" eval="False"/>
</record>

<menuitem
action = "adm_sessions_tree_view2"
id = "adm_session_menu"
parent = "pos_divina_custom.menu_point_of_sale2"
name = "Adm Sessions"
sequence= "12"/>
</odoo>

Tree view is correctly loaded and linked to my menu but clicking on record doesn't open the respective form.

I don't need to edit the form, but just show all the other fields (even if now are the same shown on tree).

What are the missing bits?

Avatar
Discard
Author Best Answer

Solved adding the line

<field name = "view_id" eval="False"/>

on the tree view (was missing) and after correcting the typo on

<field name = "view_mode">tree,form</field>

(view,form without space as pointed out by Cybrosys). 

Avatar
Discard
Best Answer

Hi,

Remove the extra space you have added in front of the form in the below line,

       <field name = "view_mode">tree, form</field>


See Updated code,


<record id = "adm_sessions_tree_view2" model = "ir.actions.act_window">
<field name = "name">AdM sessions</field>
<field name = "type">ir.actions.act_window</field>
<field name = "res_model">pos.adm</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree,form</field>
<field name = "view_id" ref= "adm_sessions_tree_view"/>
</record>


Thanks

Avatar
Discard
Author

indeed the space was a typo, thanks to point it out. Anyway updating with your code generates just an empty form in edit mode.

Author

Found the issue, on the tree view the line

<field name = "view_id" eval="False"/>

is missing. With it the form model open just fine.

Best Answer

Hello

you have to add the actions like below code. for your reference, in odoo same example is available for the Customer Invoice menu and Vendor Bills.

for example.

        <record id="action_invoice_tree_view1" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="adm_sessions_tree_view"/>
            <field name="act_window_id" ref="adm_sessions_tree_view2"/>
        </record>
        <record id="action_invoice_form_view1" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="adm_sessions_form_view"/>
            <field name="act_window_id" ref="adm_sessions_tree_view2"/>
        </record>


Avatar
Discard
Author

Thanks, but was just an error on my code.

Best Answer

Hello

you have to add the below highlights in actions.

for ex.

        <record id = "adm_sessions_tree_view2" model = "ir.actions.act_window">
           <field name = "name">AdM sessions</field>
<field name = "type">ir.actions.act_window</field>
<field name = "res_model">pos.adm</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree,form</field>
<field name = "view_id" ref= "adm_sessions_tree_view"/>
</record>

Avatar
Discard
Author

The issue was already solved.

Related Posts Replies Views Activity
2
Nov 23
5934
0
Mar 17
3440
4
Oct 17
9129
5
Jun 20
4988
0
Dec 19
3546