Skip to Content
Menu
This question has been flagged
1 Reply
3192 Views

Hello, I am developing a module and trying to implement a tree view of vehicles from fleet.vehicle module. Even though I'm specifying which fields to show, Odoo i showing completely different ones. Here's my complete xml file:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id='tms_vehicle_action' model='ir.actions.act_window'>
        <field name="name">Vehicles</field>
        <field name="res_model">fleet.vehicle</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,graph</field>
    </record>

    <!-- Tree(list) View -->
    <record id="tms_vehicle_view_tree" model="ir.ui.view">
        <field name="name">vehicles List</field>
        <field name="model">fleet.vehicle</field>
        <field name="arch" type="xml">
            <tree>
                <field name="name"/>
                <field name="order_count"/>
                <field name="seats"/>
            </tree>
        </field>
    </record>

    <record id="tms_vehicle_graph" model="ir.ui.view" >
        <field name="name">vehicle graph</field>
        <field name="model">fleet.vehicle</field>
        <field name="type">graph</field>
        <field name="arch" type="xml">
            <graph string="Orders younger than 30 days">
                <field name="name"/>
                <field name="moyoc_stored" type="measure"/>
            </graph>
        </field>
    </record>

    <menuitem name="Vehicles" id="tms_vehicle_menu" parent="tms_base_menu" sequence="3"/>
    <menuitem id="tms_vehicle_menu_item" parent="tms_vehicle_menu" action="tms_vehicle_action"/>
</odoo>

Tree view should only show name, order_count, and seats fields, but is currently showing the same fields as the tree view in Fleet module. How can I customize my tree view to show only specific fields?



Avatar
Discard
Best Answer

Hi,

Along with the action of the menu item, you have to specify which views has to be shown. If not specified, Odoo will show the view with lowest priority, if the priorities are same, then the view with the lowest id will be shown.


So here in your case, you have to specify the views in the action.

Sample:

<record id="mrp_workcenter_action" model="ir.actions.act_window">
<field name="name">Work Centers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workcenter</field>
<field name="view_mode">tree,kanban,form</field>
<field name="view_id" ref="mrp_workcenter_tree_view"/>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp_workcenter_tree_view')}),
(0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp_workcenter_view_kanban')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('mrp_workcenter_view')})]"/>

<field name="search_view_id" ref="view_mrp_workcenter_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new work center
</p>
</field>
</record>


See: Handling Of Multiples Views For Same Model In Odoo


Thanks

Avatar
Discard
Related Posts Replies Views Activity
5
Jun 20
4988
1
Apr 16
3646
2
Mar 15
5155
1
May 24
764
0
Jan 24
1087