[ADD] idea : Idea Vote statistics report

bzr revid: vir@tinyerp.com-20100628120853-lmn9jivy2ffgzpl0
This commit is contained in:
Vir (Open ERP)
2010-06-28 17:38:53 +05:30
parent 69ea761e14
commit 7d46e86cf9
6 changed files with 194 additions and 16 deletions
+1
View File
@@ -21,5 +21,6 @@
import idea
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -39,6 +39,7 @@
'wizard/idea_post_vote_view.xml',
'idea_view.xml',
'idea_workflow.xml',
'report/report_vote_view.xml',
'security/idea_security.xml',
'security/ir.model.access.csv',
],
+1 -16
View File
@@ -149,20 +149,6 @@
<field name="arch" type="xml">
<search string="Ideas vote">
<group col="10" colspan="4">
<filter icon="terp-go-year" string=" 365 Days "
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Tasks performed in last 365 days"/>
<filter icon="terp-go-month" string=" 30 Days "
name="month"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Tasks performed in last 30 days"/>
<filter icon="terp-go-week"
string=" 7 Days "
name="week"
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Tasks during last 7 days"/>
<separator orientation="vertical"/>
<field name="idea_id" widget="selection"/>
<field name="user_id" string="User"/>
</group>
@@ -385,10 +371,9 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_idea_vote_search"/>
<field name="context">{'search_default_week':1}</field>
</record>
<menuitem name="Votes" parent="menu_idea_reporting" id="menu_idea_vote" action="action_idea_vote"/>
<menuitem name="Votes" parent="menu_ideas1" id="menu_idea_vote" action="action_idea_vote"/>
</data>
</openerp>
+23
View File
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import report_vote
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+78
View File
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
from osv import fields,osv
class report_vote(osv.osv):
_name = "report.vote"
_description = "Idea Vote Statistics"
_auto = False
_rec_name = 'date'
_columns = {
'date': fields.date('Date Order', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'user_id': fields.many2one('res.users', 'User Name'),
'score': fields.integer('Score'),
'idea_id': fields.many2one('idea.idea', 'Idea'),
'nbr':fields.integer('# of Lines', readonly=True),
'idea_state': fields.selection([('draft', 'Draft'),('open', 'Opened'),
('close', 'Accepted'),
('cancel', 'Cancelled')],
'State'),
'category_id': fields.many2one('idea.category', 'Category'),
'creater_id': fields.many2one('res.users', 'User Name'),
}
_order = 'date desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_vote')
cr.execute("""
create or replace view report_vote as (
select
min(iv.id) as id,
count(*) as nbr,
to_date(to_char(iv.date, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
to_char(iv.date, 'YYYY') as year,
to_char(iv.date, 'MM') as month,
to_char(iv.date, 'YYYY-MM-DD') as day,
iv.user_id as user_id,
iv.idea_id as idea_id,
ii.state as idea_state,
ii.user_id as creater_id,
ii.category_id,
(sum(CAST(iv.score as integer))/count(iv.*)) as score
from
idea_vote as iv
left join idea_idea as ii on (ii.id = iv.idea_id)
group by
iv.id ,to_char(iv.date, 'dd-MM-YYYY'),to_char(iv.date, 'YYYY'),
to_char(iv.date, 'MM'),to_char(iv.date, 'YYYY-MM-DD'),ii.state,
iv.user_id,ii.user_id,ii.category_id,iv.idea_id
)
""")
report_vote()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+90
View File
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_report_vote_tree" model="ir.ui.view">
<field name="name">report.vote.tree</field>
<field name="model">report.vote</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Idea Vote Analysis">
<field name="date" invisible="1"/>
<field name="year" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="idea_id" invisible="1"/>
<field name="idea_state"/>
<field name="creater_id" invisible="1"/>
<field name="category_id" invisible="1"/>
<field name="nbr" sum="# of Lines"/>
<field name="score" sum="Score"/>
</tree>
</field>
</record>
<record id="view_report_vote_search" model="ir.ui.view">
<field name="name">report.vote.search</field>
<field name="model">report.vote</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Idea Vote Analysis">
<group>
<filter icon="terp-go-year" string=" 365 Days "
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Idea Vote created last 365 days"/>
<filter icon="terp-go-month" string=" 30 Days "
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Idea Vote created in last 30 days"/>
<filter icon="terp-go-week"
string=" 7 Days "
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Idea Vote created last 7 days"/>
<separator orientation="vertical"/>
<filter icon="terp-go-today"
string=" Today "
name="today"
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d'))]"
help="Idea Vote created by today"/>
<separator orientation="vertical"/>
<filter icon="terp-camera_test"
string="Open"
domain="[('idea_state','=',('open'))]"/>
<filter icon="terp-camera_test"
string="Accepted"
domain="[('idea_state','=',('close'))]"/>
<filter icon="terp-gtk-stop"
string="Refused"
domain="[('idea_state','=',('cancel'))]"/>
</group>
<newline/>
<group expand="0" string="Group By..." colspan="10" col="12">
<filter string="Idea" icon="terp-personal" context="{'group_by':'idea_id'}"/>
<filter string="Category" icon="terp-stock_symbol-selection" context="{'group_by':'category_id'}"/>
<separator orientation="vertical"/>
<filter string="User" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
<filter string="Creater" icon="terp-personal" context="{'group_by':'creater_id'}"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'idea_state'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
</group>
</search>
</field>
</record>
<record id="action_report_vote_all" model="ir.actions.act_window">
<field name="name">Idea Vote Analysis</field>
<field name="res_model">report.vote</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_report_vote_search"/>
<field name="context">{'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field>
</record>
<menuitem action="action_report_vote_all" id="menu_report_vote_all" parent="menu_idea_reporting" sequence="1"/>
</data>
</openerp>