Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo Boolean Graph?

I'd like to display a graph in odoo. in which i have two fields:

Date in the x-axis.

Boolean in the y-axis.

odoo use the nvd3.js to display this charts,

this is the view.xml:

<record model="ir.ui.view" id="id_view">
            <field name="name">test.base.graph.view16</field>
            <field name="model">module.base</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="test" type="bar" >
                     <field name="date" interval="day" type="row"/>
                     <field name="boolean" type="measure"/>                  
                </graph>
            </field>
</record>

this code doesn't work for me, it return an empty graph. any one have idea about this issue.

like image 905
Yacino Avatar asked Oct 31 '22 03:10

Yacino


2 Answers

Simulate both fields as integers, one by one.

Clearer: Add two additional fields:

'date_sim': fields.integer("Date simulation"), 'bool_sim': fields.integer("Bool simulation")

And for the first two fields, just add two methods decorated by @api.onchange And in their bodies just update the _sim fields with corresponding values.

And at last you should use the new fields in your view.

like image 160
Chiru Constantin - Alexandru Avatar answered Nov 15 '22 10:11

Chiru Constantin - Alexandru


Try the following:

<record model="ir.ui.view" id="id_view">
    <field name="name">test.base.graph.view16</field>
    <field name="model">module.base</field>
    <field name="arch" type="xml">
        <graph string="test" type="bar" stacked="True" interval="day">
            <field name="date" type="row" interval="day"/>
            <field name="boolean" type="measure"/>
        </graph>
    </field>
</record>
like image 37
Haresh Shyara Avatar answered Nov 15 '22 10:11

Haresh Shyara