From 4cd08109f57e2d913a7626714c0b7dd9a0becb16 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Fri, 12 Mar 2010 12:29:13 +0530 Subject: [PATCH] [ADD]:Add SQL Evaluation report. bzr revid: apa@tinyerp.com-20100312065913-h1ndpve2lv1n5j94 --- addons/hr_evaluation/__init__.py | 5 +- addons/hr_evaluation/__terp__.py | 3 +- addons/hr_evaluation/report/__init__.py | 21 ++++++ .../hr_evaluation/report/evaluation_report.py | 74 +++++++++++++++++++ .../report/evaluation_report_view.xml | 70 ++++++++++++++++++ 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 addons/hr_evaluation/report/__init__.py create mode 100644 addons/hr_evaluation/report/evaluation_report.py create mode 100644 addons/hr_evaluation/report/evaluation_report_view.xml diff --git a/addons/hr_evaluation/__init__.py b/addons/hr_evaluation/__init__.py index 7fe03d1245a..e8abcb28e1d 100644 --- a/addons/hr_evaluation/__init__.py +++ b/addons/hr_evaluation/__init__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,11 +15,12 @@ # 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 . +# along with this program. If not, see . # ############################################################################## import hr_evaluation +import report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_evaluation/__terp__.py b/addons/hr_evaluation/__terp__.py index 0a664f50a88..75fd1a1cbd7 100644 --- a/addons/hr_evaluation/__terp__.py +++ b/addons/hr_evaluation/__terp__.py @@ -32,7 +32,8 @@ "update_xml" : [ "security/ir.model.access.csv", "hr_evaluation_view.xml", - "hr_evaluation_data.xml"], + "hr_evaluation_data.xml", + "report/evaluation_report_view.xml"], "active": False, "installable": True } diff --git a/addons/hr_evaluation/report/__init__.py b/addons/hr_evaluation/report/__init__.py new file mode 100644 index 00000000000..3fee228552a --- /dev/null +++ b/addons/hr_evaluation/report/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# 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 . +# +############################################################################## +import evaluation_report \ No newline at end of file diff --git a/addons/hr_evaluation/report/evaluation_report.py b/addons/hr_evaluation/report/evaluation_report.py new file mode 100644 index 00000000000..76c6a2586d0 --- /dev/null +++ b/addons/hr_evaluation/report/evaluation_report.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import tools +from osv import fields,osv + + +class evaluation_report(osv.osv): + _name = "evaluation.report" + _description = "Evaluations Statistics" + _auto = False + _rec_name = 'date' + _columns = { + 'create_date': fields.datetime('Create Date', readonly=True), + 'deadline': fields.date("Deadline", readonly=True), + 'closed': fields.date("closed", 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), + 'employee_id': fields.many2one('hr.employee', "Employee", readonly=True), + 'nbr':fields.integer('# of Requests', readonly=True), + 'state': fields.selection([ + ('draft','Draft'), + ('wait','Plan In Progress'), + ('progress','Final Validation'), + ('done','Done'), + ('cancel','Cancelled'), + ], 'State',readonly=True), + } + _order = 'create_date desc' + def init(self, cr): + tools.drop_view_if_exists(cr, 'evaluation_report') + cr.execute(""" + create or replace view evaluation_report as ( + select + min(l.id) as id, + s.create_date as create_date, + s.employee_id, + s.date as deadline, + s.date_close as closed, + to_char(s.create_date, 'YYYY') as year, + to_char(s.create_date, 'MM') as month, + count(*) as nbr, + s.state + from + hr_evaluation_interview l + left join + hr_evaluation_evaluation s on (s.id=l.evaluation_id) + group by + s.create_date,s.state,s.employee_id, + s.date,s.date_close + ) + """) +evaluation_report() + diff --git a/addons/hr_evaluation/report/evaluation_report_view.xml b/addons/hr_evaluation/report/evaluation_report_view.xml new file mode 100644 index 00000000000..b9bcfccc776 --- /dev/null +++ b/addons/hr_evaluation/report/evaluation_report_view.xml @@ -0,0 +1,70 @@ + + + + + evaluation.report.tree + evaluation.report + tree + + + + + + + + + + + + + + + + evaluation.report.search + evaluation.report + search + + + + + + + + + + + + + + + + + + + + + + + + Evaluations + evaluation.report + form + tree,graph + + + + + + + +