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

I create new model for report. this model get its data form other models using select statement in init method. And I use graph view to show this model.

the problem is no data selected.

and graph view show:

No data to display.

No data available for this graph. Try to add some records, or make sure that there is at least one measure and no active filter in the search bar.


please can you help me


doctor_call_report.py

# -*- coding: utf-8 -*-

from openerp import fields, models, api, tools

class dz_all_report(models.Model):

_name = 'dz.all.report'

user_id = fields.Many2one('res.users', ondelete = 'set null', string='Salesperson', index=True)

doctor_id = fields.Many2one('res.partner', ondelete = 'set null', string='Doctor', index=True)

date = fields.Date(string='Date')

nbr_planned_call = fields.Integer(string='Planned Calls')

# nbr_created_call = fields.Integer(string='Created Calls')

def init(self, cr):

tools.drop_view_if_exists(cr, 'dz_all_report_graph')

cr.execute("""

create or replace view dz_all_report_graph as (

select

a.date as date,

a.user_id as user_id,

a.doctor_id as doctor_id,

a.nbr_planned_call as nbr_planned_call

from

dz_calltable a

)""")


doctor_call_report_view.xml

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="dz_all_report_search" model="ir.ui.view">

<field name="name">dz.call.table.report.search</field>

<field name="model">dz.all.report</field>

<field name="arch" type="xml">

<search string="Analytic Entries Analysis">

<field name="date"/>

<field name="doctor_id" />

<field name="user_id"/>

<group expand="0" string="Group By">

<filter string="SalesPersons" context="{'group_by':'user_id'}"/>

<filter string="Doctors" name="Doctors" context="{'group_by':'doctor_id'}" />

<separator/>

<filter string="Month" name="Month" context="{'group_by':'date:month'}"/>

</group>

</search>

</field>

</record>

<record id="dz_all_report_graph" model="ir.ui.view">

<field name="name">dz.report.graph.view</field>

<field name="model">dz.all.report</field>

<field name="arch" type="xml">

<graph string="Analytic Report" type="pivot">

<field name="user_id" type="row"/>

<field name="date" interval="month" type="col"/>

<field name="nbr_planned_call" type="measure"/>

</graph>

</field>

</record>

<record id="dz_all_report_tree" model="ir.ui.view">

<field name="name">dz.report.tree.view</field>

<field name="model">dz.all.report</field>

<field name="arch" type="xml">

<tree string="Tree view" editable="top">

<field name="user_id"/>

<field name="doctor_id" options="{'no_create': True}"/>

<field name="date" widget="date" interval="month"/>

<field name="nbr_planned_call" widget="integer" width="10%"/>

</tree>

</field>

</record>

<record id="dz_all_report_action" model="ir.actions.act_window">

<field name="name">Doctor Call report</field>

<field name="res_model">dz.all.report</field>

<field name="view_type">form</field>

<field name="view_mode">graph,tree</field>

<!--<field name="search_view_id" ref="view_analytic_entries_report_search"/>-->

<!--<field name="context">{'group_by_no_leaf':1, 'search_default_Account':1, 'group_by':[]}</field>-->

<field name="help">Doctor Call Report</field>

</record>

<menuitem action="dz_all_report_action"

id="dz_all_report_menu"

groups="base.group_sale_manager"

parent="base.next_id_64" name="Doctor Call Plan"/>

</data>

</openerp>

Avatar
Discard
Best Answer

The data you need is taken from the table dz_calltable, if that table is empty your view will see no data when created or accessed. You need to populate that table to see a result

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 15
7917
1
Jul 24
3460
2
Jan 24
10134
1
Aug 23
12546
1
Aug 23
11041