[IMP] report on hr_timesheet + fixes

bzr revid: fp@tinyerp.com-20100625100743-m0sklyrvtad4ykoy
This commit is contained in:
Fabien Pinckaers 2010-06-25 12:07:43 +02:00
parent 5bf12997cc
commit fde1a06f5a
7 changed files with 235 additions and 60 deletions

View File

@ -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',

View File

@ -19,8 +19,7 @@
#
##############################################################################
import hr_timesheet_report
import user_timesheet
import users_timesheet
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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 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()

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_timesheet_report_graph" model="ir.ui.view">
<field name="name">hr.timesheet.report.graph</field>
<field name="model">hr.timesheet.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Timesheet" type="bar">
<field name="user_id" />
<field name="quantity" operator = "+"/>
</graph>
</field>
</record>
<record id="view_hr_timesheet_report_tree" model="ir.ui.view">
<field name="name">hr.timesheet.report.tree</field>
<field name="model">hr.timesheet.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Timesheet Analysis">
<field name="year" invisible="1"/>
<field name="month" invisible="1"/>
<field name="date" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="account_id" invisible="1"/>
<field name="general_account_id" invisible="1"/>
<field name="quantity" sum="Hours"/>
<field name="cost" sum="Total Cost"/>
</tree>
</field>
</record>
<record id="view_hr_timesheet_report_search" model="ir.ui.view">
<field name="name">hr.timesheet.report.search</field>
<field name="model">hr.timesheet.report</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Timesheet">
<group col="10" colspan="12">
<filter icon="terp-go-year" string="This Year"
name="year"
domain="[('year','=', time.strftime('%%Y'))]"
help="Timesheet in this year"/>
<filter icon="terp-go-month" string="This Month"
name="month"
domain="[('month','=', time.strftime('%%m'))]"
help="Timesheet in this month"/>
<filter icon="terp-go-week"
string="Today"
domain="[('date','=', time.strftime('%%Y-%%m-%%d'))]"
help="Timesheet dof the day"/>
<separator orientation="vertical"/>
<field name="account_id"/>
<field name="user_id" />
<field name="date" />
</group>
<newline/>
<group expand="1" string="Group By...">
<filter string="User" name="group_user_id" icon="terp-personal" context="{'group_by':'user_id'}"/>
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'account_id'}"/>
<filter string="General Account" icon="terp-folder-orange" context="{'group_by':'general_account_id'}"/>
<separator orientation="vertical"/>
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'date'}"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
</group>
<newline/>
<group expand="0" string="Extended options..." groups="base.group_extended">
<field name="general_account_id"/>
<field name="product_id"/>
<field name="journal_id"/>
<separator orientation="vertical"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
</group>
</search>
</field>
</record>
<record id="action_hr_timesheet_report_stat_all" model="ir.actions.act_window">
<field name="name">Timesheet Analysis</field>
<field name="res_model">hr.timesheet.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="context">{'search_default_month':1,'search_default_group_user_id':1,'group_by_no_leaf':1,'group_by':[]}</field>
</record>
<menuitem
action="action_hr_timesheet_report_stat_all"
id="menu_hr_timesheet_report_all"
parent="menu_hr_reporting_timesheet" sequence="0"/>
</data>
</openerp>

View File

@ -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:

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
6 access_hr_sign_out_project hr.sign.out.project model_hr_sign_out_project hr.group_hr_user 1 1 1 1
7 access_hr_analytal_timesheet_employee hr.analytical.timesheet.employee model_hr_analytical_timesheet_employee hr.group_hr_manager 1 1 1 1
8 access_hr_analytal_timesheet_user hr.analytical.timesheet.user model_hr_analytical_timesheet_users hr.group_hr_user 1 1 1 1
9 access_hr_timesheet_report hr.timesheet.report model_hr_timesheet_report hr.group_hr_manager 1 0 0 0

View File

@ -8,8 +8,8 @@
<field name="arch" type="xml">
<graph string="Timesheet" type="bar">
<field name="user_id" />
<field name="quantity" operator = "+"/>
<field name="state" group = "True"/>
<field name="quantity" operator = "+"/>
<field name="state" group = "True"/>
</graph>
</field>
</record>
@ -50,71 +50,71 @@
<search string="Timesheet">
<group col="10" colspan="12">
<filter icon="terp-go-year" string="This Year"
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')),('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet in this year"/>
<filter icon="terp-go-month" string="This Month"
name="month"
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet in this month"/>
<filter icon="terp-go-week"
string=" 7 Days "
separator="1"
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet during last 7 days"/>
<separator orientation="vertical"/>
<filter icon="terp-document-new"
string="Draft"
domain="[('state','=','draft')]"/>
<filter icon="terp-camera_test"
string="Confirmed"
domain="[('state','=','confirm')]"/>
<filter icon="terp-dialog-close"
string="Done"
domain="[('state','=','done')]"/>
<separator orientation="vertical"/>
<field name="account_id"/>
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')),('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet in this year"/>
<filter icon="terp-go-month" string="This Month"
name="month"
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet in this month"/>
<filter icon="terp-go-week"
string=" 7 Days "
separator="1"
domain="[('date_current','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date_current','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Timesheet during last 7 days"/>
<separator orientation="vertical"/>
<filter icon="terp-document-new"
string="Draft"
domain="[('state','=','draft')]"/>
<filter icon="terp-camera_test"
string="Confirmed"
domain="[('state','=','confirm')]"/>
<filter icon="terp-dialog-close"
string="Done"
domain="[('state','=','done')]"/>
<separator orientation="vertical"/>
<field name="account_id"/>
<field name="user_id" />
</group>
<newline/>
<group expand="1" string="Group By...">
<filter string="User" name="User_id" icon="terp-personal" context="{'group_by':'user_id'}"/>
<filter string="Department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
<separator orientation="vertical"/>
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter string="Type of Invoicing" icon="terp-stock_symbol-selection" context="{'group_by':'to_invoice'}"/>
<separator orientation="vertical"/>
<filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'account_id'}"/>
<filter string="General Account" icon="terp-folder-orange" context="{'group_by':'general_account_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
<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'}"/>
<filter string="User" name="User_id" icon="terp-personal" context="{'group_by':'user_id'}"/>
<filter string="Department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
<separator orientation="vertical"/>
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter string="Type of Invoicing" icon="terp-stock_symbol-selection" context="{'group_by':'to_invoice'}"/>
<separator orientation="vertical"/>
<filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'account_id'}"/>
<filter string="General Account" icon="terp-folder-orange" context="{'group_by':'general_account_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
<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>
<newline/>
<group expand="0" string="Extended options..." groups="base.group_extended">
<field name="general_account_id"/>
<field name="to_invoice" widget="selection"/>
<separator orientation="vertical"/>
<field name="product_id"/>
<separator orientation="vertical"/>
<field name="department_id" widget="selection"/>
<separator orientation="vertical"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<newline/>
<field name="date_to"/>
<field name="date_from"/>
</group>
<field name="general_account_id"/>
<field name="to_invoice" widget="selection"/>
<separator orientation="vertical"/>
<field name="product_id"/>
<separator orientation="vertical"/>
<field name="department_id" widget="selection"/>
<separator orientation="vertical"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
<newline/>
<field name="date_to"/>
<field name="date_from"/>
</group>
</search>
</field>
</record>
<record id="action_timesheet_report_stat_all" model="ir.actions.act_window">
<field name="name">Timesheet</field>
<field name="name">Timesheet Sheet Analysis</field>
<field name="res_model">timesheet.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>