diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index 930877b77c2..601bf134598 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -42,6 +42,7 @@ to set up a management by affair. 'update_xml': [ 'security/ir.model.access.csv', 'hr_timesheet_view.xml', + 'report/hr_timesheet_report_view.xml', 'hr_timesheet_report.xml', 'hr_timesheet_wizard.xml', 'process/hr_timesheet_process.xml', diff --git a/addons/hr_timesheet/report/__init__.py b/addons/hr_timesheet/report/__init__.py index 156a4b83c63..d54615fbd0b 100644 --- a/addons/hr_timesheet/report/__init__.py +++ b/addons/hr_timesheet/report/__init__.py @@ -19,8 +19,7 @@ # ############################################################################## +import hr_timesheet_report import user_timesheet import users_timesheet -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/hr_timesheet/report/hr_timesheet_report.py b/addons/hr_timesheet/report/hr_timesheet_report.py new file mode 100644 index 00000000000..100041ca35a --- /dev/null +++ b/addons/hr_timesheet/report/hr_timesheet_report.py @@ -0,0 +1,78 @@ +# -*- 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 hr_timesheet_report(osv.osv): + _name = "hr.timesheet.report" + _description = "Timesheet" + _auto = False + _columns = { + 'year': 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), + 'date': fields.date('Date', readonly=True), + 'name': fields.char('Description', size=64,readonly=True), + 'product_id' : fields.many2one('product.product', 'Product',readonly=True), + 'journal_id' : fields.many2one('account.analytic.journal', 'Journal',readonly=True), + 'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True), + 'user_id': fields.many2one('res.users', 'User',readonly=True), + 'account_id': fields.many2one('account.analytic.account', 'Analytic Account',readonly=True), + 'company_id': fields.many2one('res.company', 'Company',readonly=True), + 'cost': fields.float('Cost',readonly=True), + 'quantity': fields.float('Quantity',readonly=True), + } + + def init(self, cr): + tools.drop_view_if_exists(cr, 'hr_timesheet_report') + cr.execute(""" + create or replace view hr_timesheet_report as ( + select + min(t.id) as id, + l.date as date, + to_char(l.date,'YYYY') as year, + to_char(l.date,'MM') as month, + sum(l.amount) as cost, + sum(l.unit_amount) as quantity, + l.account_id as account_id, + l.journal_id as journal_id, + l.product_id as product_id, + l.general_account_id as general_account_id, + l.user_id as user_id, + l.company_id as company_id, + l.currency_id as currency_id + from + hr_analytic_timesheet as t + left join account_analytic_line as l ON (t.line_id=l.id) + group by + l.date, + l.account_id, + l.product_id, + l.general_account_id, + l.journal_id, + l.user_id, + l.company_id, + l.currency_id + ) + """) +hr_timesheet_report() diff --git a/addons/hr_timesheet/report/hr_timesheet_report_view.xml b/addons/hr_timesheet/report/hr_timesheet_report_view.xml new file mode 100644 index 00000000000..7f2df2e815e --- /dev/null +++ b/addons/hr_timesheet/report/hr_timesheet_report_view.xml @@ -0,0 +1,99 @@ + + + + + hr.timesheet.report.graph + hr.timesheet.report + graph + + + + + + + + + hr.timesheet.report.tree + hr.timesheet.report + tree + + + + + + + + + + + + + + + + + + + + hr.timesheet.report.search + hr.timesheet.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Timesheet Analysis + hr.timesheet.report + form + tree,graph + {'search_default_month':1,'search_default_group_user_id':1,'group_by_no_leaf':1,'group_by':[]} + + + + diff --git a/addons/hr_timesheet/report/user_timesheet.py b/addons/hr_timesheet/report/user_timesheet.py index 8dbda07ea76..d444e4a19bc 100644 --- a/addons/hr_timesheet/report/user_timesheet.py +++ b/addons/hr_timesheet/report/user_timesheet.py @@ -101,6 +101,3 @@ class report_custom(report_rml): report_custom('report.hr.analytical.timesheet', 'hr.employee', '', 'addons/hr_timesheet/report/user_timesheet.xsl') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/hr_timesheet/security/ir.model.access.csv b/addons/hr_timesheet/security/ir.model.access.csv index ce340fb4eb9..d0573745208 100644 --- a/addons/hr_timesheet/security/ir.model.access.csv +++ b/addons/hr_timesheet/security/ir.model.access.csv @@ -6,3 +6,4 @@ "access_hr_sign_out_project","hr.sign.out.project","model_hr_sign_out_project","hr.group_hr_user",1,1,1,1 "access_hr_analytal_timesheet_employee","hr.analytical.timesheet.employee","model_hr_analytical_timesheet_employee","hr.group_hr_manager",1,1,1,1 "access_hr_analytal_timesheet_user","hr.analytical.timesheet.user","model_hr_analytical_timesheet_users","hr.group_hr_user",1,1,1,1 +"access_hr_timesheet_report","hr.timesheet.report","model_hr_timesheet_report","hr.group_hr_manager",1,0,0,0 diff --git a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/timesheet_report_view.xml index d628c119530..a5d7d9b420f 100644 --- a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml +++ b/addons/hr_timesheet_sheet/report/timesheet_report_view.xml @@ -8,8 +8,8 @@ - - + + @@ -50,71 +50,71 @@ - - - - - - - - + domain="[('date_current','<=', time.strftime('%%Y-%%m-%%d')),('date_current','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]" + help="Timesheet in this year"/> + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - Timesheet + Timesheet Sheet Analysis timesheet.report form tree,graph