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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With