diff --git a/addons/hr_timesheet/__init__.py b/addons/hr_timesheet/__init__.py index 0ba28b1946c..f29aca0a003 100644 --- a/addons/hr_timesheet/__init__.py +++ b/addons/hr_timesheet/__init__.py @@ -21,6 +21,7 @@ import hr_timesheet import wizard +import report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index b2e6c9f9cc1..49e65b41753 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -47,6 +47,7 @@ up a management by affair. 'security/hr_timesheet_security.xml', 'hr_timesheet_view.xml', 'wizard/hr_timesheet_sign_in_out_view.xml', + 'report/hr_timesheet_report_view.xml', 'hr_timesheet_installer.xml', 'hr_timesheet_data.xml' ], diff --git a/addons/hr_timesheet/report/__init__.py b/addons/hr_timesheet/report/__init__.py new file mode 100644 index 00000000000..8728fb520b6 --- /dev/null +++ b/addons/hr_timesheet/report/__init__.py @@ -0,0 +1 @@ +import hr_timesheet_report 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..3ed396feefa --- /dev/null +++ b/addons/hr_timesheet/report/hr_timesheet_report.py @@ -0,0 +1,76 @@ + +from openerp import tools +from openerp.osv import fields,osv +from openerp.addons.decimal_precision import decimal_precision as dp + +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), + 'day': fields.char('Day', size=128, 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, digits_compute=dp.get_precision('Account')), + 'quantity': fields.float('Time',readonly=True), + } + + def _select(self): + select_str = """ + SELECT min(hat.id) as id, + aal.date as date, + to_char(aal.date, 'YYYY-MM-DD') as day, + to_char(aal.date,'YYYY') as year, + to_char(aal.date,'MM') as month, + sum(aal.amount) as cost, + sum(aal.unit_amount) as quantity, + aal.account_id as account_id, + aal.journal_id as journal_id, + aal.product_id as product_id, + aal.general_account_id as general_account_id, + aal.user_id as user_id, + aal.company_id as company_id, + aal.currency_id as currency_id + """ + return select_str + + def _from(self): + from_str = """ + account_analytic_line as aal + left join hr_analytic_timesheet as hat ON (hat.line_id=aal.id) + """ + return from_str + + def _group_by(self): + group_by_str = """ + GROUP BY aal.date, + aal.account_id, + aal.product_id, + aal.general_account_id, + aal.journal_id, + aal.user_id, + aal.company_id, + aal.currency_id + """ + return group_by_str + + def init(self, cr): + # self._table = hr_timesheet_report + tools.drop_view_if_exists(cr, self._table) + cr.execute("""CREATE or REPLACE VIEW %s as ( + %s + FROM ( %s ) + %s + )""" % (self._table, self._select(), self._from(), self._group_by())) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 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..ec97447d7ff --- /dev/null +++ b/addons/hr_timesheet/report/hr_timesheet_report_view.xml @@ -0,0 +1,58 @@ + + + + + hr.timesheet.report.graph + hr.timesheet.report + + + + + + + + + + + + hr.timesheet.report.search + hr.timesheet.report + + + + + + + + + + + + + + + + + + + + + + + + + + + + Timesheet Analysis + hr.timesheet.report + form + graph + {'search_default_year':1,'search_default_month':1,'search_default_group_user_id':1,'group_by_no_leaf':1,'group_by':[]} + + + + + + diff --git a/addons/hr_timesheet_sheet/__openerp__.py b/addons/hr_timesheet_sheet/__openerp__.py index 9448c3fb7c1..7ecae95e141 100644 --- a/addons/hr_timesheet_sheet/__openerp__.py +++ b/addons/hr_timesheet_sheet/__openerp__.py @@ -53,7 +53,6 @@ The validation can be configured in the company: 'hr_timesheet_sheet_view.xml', 'hr_timesheet_workflow.xml', 'report/hr_timesheet_report_view.xml', - 'report/timesheet_report_view.xml', 'wizard/hr_timesheet_current_view.xml', 'hr_timesheet_sheet_data.xml', 'res_config_view.xml', diff --git a/addons/hr_timesheet_sheet/report/__init__.py b/addons/hr_timesheet_sheet/report/__init__.py index b06b0608356..9a95bc4a787 100644 --- a/addons/hr_timesheet_sheet/report/__init__.py +++ b/addons/hr_timesheet_sheet/report/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import timesheet_report import hr_timesheet_report + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py index e15ae99ab5a..7cc59372d0a 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py @@ -21,55 +21,62 @@ from openerp import tools from openerp.osv import fields,osv -from openerp.addons.decimal_precision import decimal_precision as dp - class hr_timesheet_report(osv.osv): - _name = "hr.timesheet.report" - _description = "Timesheet" - _auto = False + _inherit = "hr.timesheet.report" _columns = { - '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, digits_compute=dp.get_precision('Account')), - 'quantity': fields.float('Time',readonly=True), - } + 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Type of Invoicing',readonly=True), + 'nbr': fields.integer('#Nbr',readonly=True), + 'total_diff': fields.float('#Total Diff',readonly=True), + 'total_timesheet': fields.float('#Total Timesheet',readonly=True), + 'total_attendance': fields.float('#Total Attendance',readonly=True), + 'department_id':fields.many2one('hr.department','Department',readonly=True), + 'date_from': fields.date('Date from',readonly=True,), + 'date_to': fields.date('Date to',readonly=True), + 'date_current': fields.date('Current date', required=True), + 'state' : fields.selection([ + ('new', 'New'), + ('draft','Draft'), + ('confirm','Confirmed'), + ('done','Done')], 'Status', readonly=True), + } + + def _select(self): + return super(hr_timesheet_report, self)._select() + """, + htss.name, + htss.date_from, + htss.date_to, + count(*) as nbr, + (SELECT sum(day.total_difference) + FROM hr_timesheet_sheet_sheet AS sheet + LEFT JOIN hr_timesheet_sheet_sheet_day AS day + ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_diff, + (SELECT sum(day.total_timesheet) + FROM hr_timesheet_sheet_sheet AS sheet + LEFT JOIN hr_timesheet_sheet_sheet_day AS day + ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_timesheet, + (SELECT sum(day.total_attendance) + FROM hr_timesheet_sheet_sheet AS sheet + LEFT JOIN hr_timesheet_sheet_sheet_day AS day + ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_attendance, + aal.to_invoice, + htss.department_id, + htss.state""" + + def _from(self): + return super(hr_timesheet_report, self)._from() + "left join hr_timesheet_sheet_sheet as htss ON (hat.sheet_id=htss.id)" + + def _group_by(self): + return super(hr_timesheet_report, self)._group_by() + """, + htss.date_from, + htss.date_to, + aal.unit_amount, + aal.amount, + aal.to_invoice, + htss.name, + htss.state, + htss.id, + htss.department_id""" - 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, - 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 - ) - """) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml index 30757a0b43e..6c735123efe 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml @@ -1,65 +1,49 @@ - - hr.timesheet.report.graph + + timesheet.report.graph hr.timesheet.report + - - - - - - - - - - hr.timesheet.report.search - hr.timesheet.report - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - Timesheet Analysis - hr.timesheet.report - form - graph - {'search_default_month':1,'search_default_group_user_id':1,'group_by_no_leaf':1,'group_by':[]} - -

- This report performs analysis on timesheets created by your - human resources in the system. It allows you to have a full - overview of entries done by your employees. You can group them - by specific selection criteria thanks to the search tool. -

+ + timesheet.report.search + hr.timesheet.report + + + + + + + + + + + + + + + + + + + + + + - +
diff --git a/addons/hr_timesheet_sheet/report/timesheet_report.py b/addons/hr_timesheet_sheet/report/timesheet_report.py deleted file mode 100644 index 6d284ac08c8..00000000000 --- a/addons/hr_timesheet_sheet/report/timesheet_report.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- 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 . -# -############################################################################## - -from openerp import tools -from openerp.osv import fields,osv - -class timesheet_report(osv.osv): - _name = "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), - 'day': fields.char('Day', size=128, readonly=True), - 'date': fields.date('Date', readonly=True), - 'name': fields.char('Description', size=64,readonly=True), - 'product_id' : fields.many2one('product.product', 'Product'), - 'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True), - 'user_id': fields.many2one('res.users', 'User',readonly=True), - 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Type of Invoicing',readonly=True), - 'account_id': fields.many2one('account.analytic.account', 'Analytic Account',readonly=True), - 'nbr': fields.integer('#Nbr',readonly=True), - 'total_diff': fields.float('#Total Diff',readonly=True), - 'total_timesheet': fields.float('#Total Timesheet',readonly=True), - 'total_attendance': fields.float('#Total Attendance',readonly=True), - 'company_id': fields.many2one('res.company', 'Company',readonly=True), - 'department_id':fields.many2one('hr.department','Department',readonly=True), - 'date_from': fields.date('Date from',readonly=True,), - 'date_to': fields.date('Date to',readonly=True), - 'date_current': fields.date('Current date', required=True), - 'state' : fields.selection([ - ('new', 'New'), - ('draft','Draft'), - ('confirm','Confirmed'), - ('done','Done')], 'Status', readonly=True), - 'quantity': fields.float('Time',readonly=True), - 'cost': fields.float('#Cost',readonly=True), - } - - def init(self, cr): - tools.drop_view_if_exists(cr, 'timesheet_report') - cr.execute(""" - create or replace view timesheet_report as ( - select - min(aal.id) as id, - htss.name, - aal.date as date, - htss.date_from, - htss.date_to, - to_char(htss.date_from, 'YYYY-MM-DD') as day, - to_char(htss.date_from, 'YYYY') as year, - to_char(htss.date_from, 'MM') as month, - count(*) as nbr, - aal.unit_amount as quantity, - aal.amount as cost, - aal.account_id, - aal.product_id, - (SELECT sum(day.total_difference) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_diff, - (SELECT sum(day.total_timesheet) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_timesheet, - (SELECT sum(day.total_attendance) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_attendance, - aal.to_invoice, - aal.general_account_id, - htss.user_id, - htss.company_id, - htss.department_id, - htss.state - from account_analytic_line as aal - left join hr_analytic_timesheet as hat ON (hat.line_id=aal.id) - left join hr_timesheet_sheet_sheet as htss ON (hat.sheet_id=htss.id) - group by - aal.account_id, - aal.date, - htss.date_from, - htss.date_to, - aal.unit_amount, - aal.amount, - aal.to_invoice, - aal.product_id, - aal.general_account_id, - htss.name, - htss.company_id, - htss.state, - htss.id, - htss.department_id, - htss.user_id - ) - """) - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/timesheet_report_view.xml deleted file mode 100644 index 9b45229c2cc..00000000000 --- a/addons/hr_timesheet_sheet/report/timesheet_report_view.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - timesheet.report.graph - timesheet.report - - - - - - - - - - - - - - timesheet.report.search - timesheet.report - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Timesheet Sheet Analysis - timesheet.report - form - graph - {'search_default_year':1,'search_default_month':1,'search_default_User_id':1,'group_by_no_leaf':1,'group_by':[]} - - - - - diff --git a/addons/hr_timesheet_sheet/security/ir.model.access.csv b/addons/hr_timesheet_sheet/security/ir.model.access.csv index 3feb9cf1a92..8eef30b35c4 100644 --- a/addons/hr_timesheet_sheet/security/ir.model.access.csv +++ b/addons/hr_timesheet_sheet/security/ir.model.access.csv @@ -1,9 +1,8 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_hr_timesheet_sheet_sheet_user,hr_timesheet_sheet.sheet.user,model_hr_timesheet_sheet_sheet,base.group_user,1,1,1,1 -access_hr_timesheet_sheet_sheet_system_employee,hr_timesheet_sheet.sheet.system.employee,model_hr_timesheet_sheet_sheet,base.group_user,1,1,1,0 -access_hr_timesheet_sheet_sheet_day,hr_timesheet_sheet.sheet.day,model_hr_timesheet_sheet_sheet_day,base.group_hr_user,1,1,1,1 -access_hr_timesheet_sheet_sheet_account,hr_timesheet_sheet.sheet.account,model_hr_timesheet_sheet_sheet_account,base.group_hr_user,1,1,1,1 -access_hr_timesheet_report,hr.timesheet.report,model_hr_timesheet_report,base.group_hr_manager,1,1,0,0 -access_hr_analytic_timesheet_system_user,hr.analytic.timesheet.system.user,model_hr_analytic_timesheet,base.group_user,1,0,0,0 -access_hr_timesheet_sheet_sheet_day,hr.timesheet.sheet.sheet.day.user,model_hr_timesheet_sheet_sheet_day,base.group_user,1,1,1,0 -access_timesheet_report,timesheet.report,model_timesheet_report,base.group_hr_manager,1,1,0,0 +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_hr_timesheet_sheet_sheet_user,hr_timesheet_sheet.sheet.user,model_hr_timesheet_sheet_sheet,base.group_user,1,1,1,1 +access_hr_timesheet_sheet_sheet_system_employee,hr_timesheet_sheet.sheet.system.employee,model_hr_timesheet_sheet_sheet,base.group_user,1,1,1,0 +access_hr_timesheet_sheet_sheet_day,hr_timesheet_sheet.sheet.day,model_hr_timesheet_sheet_sheet_day,base.group_hr_user,1,1,1,1 +access_hr_timesheet_sheet_sheet_account,hr_timesheet_sheet.sheet.account,model_hr_timesheet_sheet_sheet_account,base.group_hr_user,1,1,1,1 +access_hr_timesheet_report,hr.timesheet.report,model_hr_timesheet_report,base.group_hr_manager,1,1,0,0 +access_hr_analytic_timesheet_system_user,hr.analytic.timesheet.system.user,model_hr_analytic_timesheet,base.group_user,1,0,0,0 +access_hr_timesheet_sheet_sheet_day,hr.timesheet.sheet.sheet.day.user,model_hr_timesheet_sheet_sheet_day,base.group_user,1,1,1,0