+4 votes

I created 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"/>                  

the code doesn't work and it return an empty graph. anyone have an idea about this issue.

in Back-end by (10.5k points) | 30 views

1 Answer

+1 vote

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.

by (4.6k points)
202 questions
178 answers
109,862 users