[ADD/MOD]hr_timesheet_sheet: Add Timesheet Sheet Analysis report
bzr revid: dbr@tinyerp.com-20101015130025-yrmt74x8soq226h0
This commit is contained in:
parent
487c36486c
commit
a971419f30
|
@ -55,6 +55,7 @@ The validation can be configured in the company:
|
|||
'process/hr_timesheet_sheet_process.xml',
|
||||
'board_hr_timesheet_view.xml',
|
||||
'report/hr_timesheet_report_view.xml',
|
||||
'report/timesheet_report_view.xml',
|
||||
'wizard/hr_timesheet_current_view.xml',
|
||||
'hr_timesheet_sheet_data.xml'
|
||||
],
|
||||
|
|
|
@ -19,5 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import timesheet_report
|
||||
import hr_timesheet_report
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
# -*- 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 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),
|
||||
'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')], 'State', readonly=True),
|
||||
'quantity': fields.float('#Quantity',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.date_current,
|
||||
htss.name,
|
||||
htss.date_from,
|
||||
htss.date_to,
|
||||
to_char(htss.date_current,'YYYY') as year,
|
||||
to_char(htss.date_current,'MM') as month,
|
||||
to_char(htss.date_current, 'YYYY-MM-DD') as day,
|
||||
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
|
||||
AND day.name = sheet.date_current) 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
|
||||
AND day.name = sheet.date_current) 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
|
||||
AND day.name = sheet.date_current) 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.line_id=htss.id)
|
||||
group by
|
||||
to_char(htss.date_current,'YYYY'),
|
||||
to_char(htss.date_current,'MM'),
|
||||
to_char(htss.date_current, 'YYYY-MM-DD'),
|
||||
aal.account_id,
|
||||
htss.date_from,
|
||||
htss.date_to,
|
||||
aal.unit_amount,
|
||||
aal.amount,
|
||||
htss.date_current,
|
||||
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
|
||||
)
|
||||
""")
|
||||
timesheet_report()
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_timesheet_report_graph" model="ir.ui.view">
|
||||
<field name="name">timesheet.report.graph</field>
|
||||
<field name="model">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 = "+"/>
|
||||
<field name="state" group = "True"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_timesheet_report_tree" model="ir.ui.view">
|
||||
<field name="name">timesheet.report.tree</field>
|
||||
<field name="model">timesheet.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:state in ('draft');black:state in ('confirm','new');gray:state in('cancel')" string="Timesheet">
|
||||
<field name="date_current" invisible="1"/>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="date_from" invisible="1"/>
|
||||
<field name="date_to" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="to_invoice" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="account_id" invisible="1"/>
|
||||
<field name="general_account_id" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="quantity" sum="#Quantity"/>
|
||||
<field name="cost" sum="#Cost"/>
|
||||
<field name="total_diff" sum="#Total Diff"/>
|
||||
<field name="total_timesheet" sum="#Total Timesheet"/>
|
||||
<field name="total_attendance" sum="#Total Attendance"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_timesheet_report_search" model="ir.ui.view">
|
||||
<field name="name">timesheet.report.search</field>
|
||||
<field name="model">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=" Year "
|
||||
domain="[('date_current','<=', time.strftime('%%Y-%%m-%%d')),('date_current','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Timesheet in current year"/>
|
||||
<filter icon="terp-go-month" string=" Month "
|
||||
name="month"
|
||||
domain="[('date_current','<=', time.strftime('%%Y-%%m-%%d')), ('date_current','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Timesheet in current month"/>
|
||||
<filter icon="terp-go-month"
|
||||
string=" Month-1 "
|
||||
domain="[('date_current','<=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date_current','>',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Timesheet of last month"/>
|
||||
<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="0" string="Extended Filters..." 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>
|
||||
<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'}" help="Group by day of date"/>
|
||||
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of date"/>
|
||||
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of date"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_timesheet_report_stat_all" model="ir.actions.act_window">
|
||||
<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>
|
||||
<field name="context">{'search_default_month':1,'search_default_User_id':1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
<field name="search_view_id" ref="view_timesheet_report_search"/>
|
||||
</record>
|
||||
<menuitem action="action_timesheet_report_stat_all" id="menu_timesheet_report_all"
|
||||
parent="hr_timesheet.menu_hr_reporting_timesheet" sequence="1" groups="base.group_hr_manager"/>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue