[IMP,MOD] Modification for adding year and month for Tasks by user report

bzr revid: vir@tinyerp.com-20091215125045-tk09aesice2v0wun
This commit is contained in:
Vir (Open ERP)
2009-12-15 18:20:45 +05:30
parent e6cc3d5184
commit 140758133a
2 changed files with 41 additions and 34 deletions
+19 -14
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -27,6 +27,9 @@ class report_task_user_pipeline_open (osv.osv):
_description = "Tasks by user and project"
_auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, 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),
'user_id':fields.many2one('res.users', 'User', readonly=True),
'task_nbr': fields.float('Task Number', readonly=True),
'task_hrs': fields.float('Task Hours', readonly=True),
@@ -40,6 +43,8 @@ class report_task_user_pipeline_open (osv.osv):
create or replace view report_task_user_pipeline_open as (
select
min(t.id) as id,
to_char(t.create_date, 'YYYY') as name,
to_char(t.create_date,'MM') as month,
u.id as user_id,
u.company_id as company_id,
count(t.*) as task_nbr,
@@ -48,12 +53,12 @@ class report_task_user_pipeline_open (osv.osv):
case when t.state is null then 'no' else t.state end as task_state
from
res_users u
left join
left join
project_task t on (u.id = t.user_id)
where
u.active
group by
u.id, u.company_id, t.state
to_char(t.create_date, 'YYYY'),to_char(t.create_date,'MM'),u.id, u.company_id, t.state
)
''')
report_task_user_pipeline_open()
@@ -99,7 +104,7 @@ class report_timesheet_task_user(osv.osv):
_name = "report.timesheet.task.user"
_auto = False
_order = "name"
def _get_task_hours(self, cr, uid, ids, name,args,context):
result = {}
for record in self.browse(cr, uid, ids,context):
@@ -112,7 +117,7 @@ class report_timesheet_task_user(osv.osv):
total += hrs['hours']
result[record.id] = total
return result
def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
result = {}
sum = 0.0
@@ -126,7 +131,7 @@ class report_timesheet_task_user(osv.osv):
total += day_attendance['total_attendance']
result[record.id] = total
return result
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'user_id': fields.many2one('res.users', 'User',readonly=True),
@@ -135,20 +140,20 @@ class report_timesheet_task_user(osv.osv):
'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),
}
def init(self, cr):
def init(self, cr):
cr.execute(""" create or replace view report_timesheet_task_user as (
select
select
((r.id*12)+to_number(months.m_id,'99'))::integer as id,
months.name as name,
r.id as user_id
from res_users r,
(select to_char(p.date,'YYYY-MM-01') as name,
to_char(p.date,'MM') as m_id
from project_task_work p
union
from project_task_work p
union
select to_char(h.name,'YYYY-MM-01') as name,
to_char(h.name,'MM') as m_id
from hr_timesheet_sheet_sheet_day h) as months) """)
+22 -20
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Tasks by projects and users -->
<record id="view_task_project_form" model="ir.ui.view">
<field name="name">report.project.task.form</field>
<field name="model">report.task.user.pipeline.open</field>
@@ -19,7 +19,7 @@
</form>
</field>
</record>
<record id="view_task_project_graph" model="ir.ui.view">
<field name="name">report.project.task.graph</field>
<field name="model">report.task.user.pipeline.open</field>
@@ -31,13 +31,15 @@
</graph>
</field>
</record>
<record id="view_task_project_tree" model="ir.ui.view">
<field name="name">report.project.task.tree</field>
<field name="model">report.task.user.pipeline.open</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Tasks by User">
<field name="name" select="1"/>
<field name="month" select="1"/>
<field name="user_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="task_nbr"/>
@@ -47,38 +49,38 @@
</tree>
</field>
</record>
<record id="view_task_project_search" model="ir.ui.view">
<field name="name">report.project.task.search</field>
<field name="model">report.project.task</field>
<record id="view_report_task_user_pipeline_open_search" model="ir.ui.view">
<field name="name">report.task.user.pipeline.open.search</field>
<field name="model">report.task.user.pipeline.open</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Tasks by User">
<group col="8" colspan="4">
<group col="10" colspan="4">
<filter icon="terp-project" string="This Year" domain="[('name','=',time.strftime('%%Y'))]" help="Tasks performed in this year"/>
<filter icon="terp-project" string="This Month" domain="[('month','=',time.strftime('%%m'))]" help="Tasks performed in this month"/>
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="month" select="1"/>
<field name="user_id" select="1"/>
<field name="project_id" select="1"/>
</group>
</group>
</search>
</field>
</record>
<record id="action_project_task" model="ir.actions.act_window">
<field name="name">Tasks by User</field>
<field name="res_model">report.task.user.pipeline.open</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="domain">[]</field>
<field name="search_view_id" ref="view_report_task_user_pipeline_open_search"/>
</record>
<menuitem id="next_id_57" name="Reporting" parent="project.menu_main" sequence="50"/>
<menuitem action="action_project_task" id="menu_project_task_user_tree" parent="next_id_57"/>
<!-- Closed Task in Random Acitivities dashboard -->
<record id="view_task_closed_board_tree" model="ir.ui.view">
<field name="name">report.closed.task.tree</field>
<field name="model">report.closed.task</field>
@@ -100,7 +102,7 @@
</tree>
</field>
</record>
<record id="action_closed_task_board" model="ir.actions.act_window">
<field name="name">Task Closed Within Past 15 Days</field>
<field name="res_model">report.closed.task</field>
@@ -108,9 +110,9 @@
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_task_closed_board_tree"/>
</record>
<!-- Report for Users' Timesheet and Task Hours per Month -->
<record id="view_report_timesheet_task_user_tree" model="ir.ui.view">
<field name="name">report.timesheet.task.user.tree</field>
<field name="model">report.timesheet.task.user</field>
@@ -124,14 +126,14 @@
</tree>
</field>
</record>
<record id="action_report_timesheet_task_user" model="ir.actions.act_window">
<field name="name">Timesheet / Task Hours Per Month</field>
<field name="res_model">report.timesheet.task.user</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<menuitem id="menu_timesheet_task_user" parent="hr.menu_hr_reporting" action="action_report_timesheet_task_user"/>
<menuitem id="menu_timesheet_task_user" parent="hr.menu_hr_reporting" action="action_report_timesheet_task_user"/>
</data>
</openerp>