Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to create report with init method and graph view?

By
Mohammad Adnan
on 9/30/15, 9:07 AM 2,080 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>

1

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/30/15, 5:11 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 9/30/15, 9:07 AM
Seen: 2080 times
Last updated: 9/30/15, 5:11 PM