为一个模型openerp创建两个图形视图

时间:2015-04-19 14:27:14

标签: openerp odoo

我想为一个模型openerp创建两个图形视图,我想定义两个菜单,每个显示一个图形视图, 按国家/地区按性别列出一个内容图

1 个答案:

答案 0 :(得分:4)

您需要在xml中创建两个图表视图。

    <record id="country_graph_id" model="ir.ui.view">
        <field name="name">country.graph</field>
        <field name="model">your.model</field>
        <field name="arch" type="xml">
            <graph string="By Country" type="bar">
                <field name="your fields"/>
                <field name="your_field2"/>
            </graph>
        </field>
    </record>

    <record id="country_gender_id" model="ir.ui.view">
        <field name="name">gender.graph</field>
        <field name="model">your.model</field>
        <field name="arch" type="xml">
            <graph string="By Gender" type="bar">
                <field name="your_field3"/>
                <field name="your_field4"/>
            </graph>
        </field>
    </record>

之后,您需要创建两个操作和两个菜单,如

<record id="action_for_country_graph" model="ir.actions.act_window">
    <field name="name">By Country</field>
    <field name="res_model">your.model</field>
    <field name="view_type">form</field>
    <field name="view_mode">graph</field>
    <field name="view_id" ref="country_graph_id"/>
</record>

<record id="action_for_gender_graph" model="ir.actions.act_window">
    <field name="name">By gender</field>
    <field name="res_model">your.model</field>
    <field name="view_type">form</field>
    <field name="view_mode">graph</field>
    <field name="view_id" ref="gender_graph_id"/>
</record>


<menuitem action="action_for_country_graph" id="menu_country_graph_id"
    sequence="1" name='Country Graph' parent='parent.menu'/>

<menuitem action="action_for_gender_graph" id="menu_gender_graph_id"
    sequence="2" name='Gender Graph' parent='parent.menu'/>