[IMP] move hr timesheet analysis report in to hr_timesheet
This commit is contained in:
parent
1870fa813d
commit
d2f3bb953d
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import hr_timesheet
|
import hr_timesheet
|
||||||
import wizard
|
import wizard
|
||||||
|
import report
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ up a management by affair.
|
||||||
'security/hr_timesheet_security.xml',
|
'security/hr_timesheet_security.xml',
|
||||||
'hr_timesheet_view.xml',
|
'hr_timesheet_view.xml',
|
||||||
'wizard/hr_timesheet_sign_in_out_view.xml',
|
'wizard/hr_timesheet_sign_in_out_view.xml',
|
||||||
|
'report/hr_timesheet_report_view.xml',
|
||||||
'hr_timesheet_installer.xml',
|
'hr_timesheet_installer.xml',
|
||||||
'hr_timesheet_data.xml'
|
'hr_timesheet_data.xml'
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
import hr_timesheet_report
|
|
@ -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:
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?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="arch" type="xml">
|
||||||
|
<graph string="Timesheet" type="pivot">
|
||||||
|
<field name="user_id" type="row"/>
|
||||||
|
<field name="date" interval="day" type="col"/>
|
||||||
|
<field name="quantity" type="measure"/>
|
||||||
|
<field name="cost" type="measure"/>
|
||||||
|
</graph>
|
||||||
|
</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="arch" type="xml">
|
||||||
|
<search string="Timesheet">
|
||||||
|
<field name="account_id"/>
|
||||||
|
<field name="user_id"/>
|
||||||
|
<filter string="This Month" name="month" icon="terp-go-year" domain="[('date','<=', time.strftime('%Y-%m-%d')),('date','>=',time.strftime('%Y-%m-01'))]" help="month"/>
|
||||||
|
<group expand="0" string="Extended Filters...">
|
||||||
|
<field name="general_account_id"/>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="journal_id"/>
|
||||||
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
|
<field name="date"/>
|
||||||
|
</group>
|
||||||
|
<group expand="1" string="Group By">
|
||||||
|
<filter string="User" name="group_user_id" icon="terp-personal" context="{'group_by':'user_id'}"/>
|
||||||
|
<filter string="Product" name="product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
||||||
|
<filter string="Analytic Account" name="analytic_account" icon="terp-folder-green" context="{'group_by':'account_id'}"/>
|
||||||
|
<filter string="General Account" name="general_account" icon="terp-folder-orange" context="{'group_by':'general_account_id'}"/>
|
||||||
|
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||||
|
<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_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">graph</field>
|
||||||
|
<field name="context">{'search_default_year':1,'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="hr.menu_hr_reporting" groups="base.group_hr_manager" sequence="3"/>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -53,7 +53,6 @@ The validation can be configured in the company:
|
||||||
'hr_timesheet_sheet_view.xml',
|
'hr_timesheet_sheet_view.xml',
|
||||||
'hr_timesheet_workflow.xml',
|
'hr_timesheet_workflow.xml',
|
||||||
'report/hr_timesheet_report_view.xml',
|
'report/hr_timesheet_report_view.xml',
|
||||||
'report/timesheet_report_view.xml',
|
|
||||||
'wizard/hr_timesheet_current_view.xml',
|
'wizard/hr_timesheet_current_view.xml',
|
||||||
'hr_timesheet_sheet_data.xml',
|
'hr_timesheet_sheet_data.xml',
|
||||||
'res_config_view.xml',
|
'res_config_view.xml',
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import timesheet_report
|
|
||||||
import hr_timesheet_report
|
import hr_timesheet_report
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -21,55 +21,62 @@
|
||||||
|
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp.osv import fields,osv
|
from openerp.osv import fields,osv
|
||||||
from openerp.addons.decimal_precision import decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class hr_timesheet_report(osv.osv):
|
class hr_timesheet_report(osv.osv):
|
||||||
_name = "hr.timesheet.report"
|
_inherit = "hr.timesheet.report"
|
||||||
_description = "Timesheet"
|
|
||||||
_auto = False
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'date': fields.date('Date', readonly=True),
|
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Type of Invoicing',readonly=True),
|
||||||
'name': fields.char('Description', size=64,readonly=True),
|
'nbr': fields.integer('#Nbr',readonly=True),
|
||||||
'product_id' : fields.many2one('product.product', 'Product',readonly=True),
|
'total_diff': fields.float('#Total Diff',readonly=True),
|
||||||
'journal_id' : fields.many2one('account.analytic.journal', 'Journal',readonly=True),
|
'total_timesheet': fields.float('#Total Timesheet',readonly=True),
|
||||||
'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True),
|
'total_attendance': fields.float('#Total Attendance',readonly=True),
|
||||||
'user_id': fields.many2one('res.users', 'User',readonly=True),
|
'department_id':fields.many2one('hr.department','Department',readonly=True),
|
||||||
'account_id': fields.many2one('account.analytic.account', 'Analytic Account',readonly=True),
|
'date_from': fields.date('Date from',readonly=True,),
|
||||||
'company_id': fields.many2one('res.company', 'Company',readonly=True),
|
'date_to': fields.date('Date to',readonly=True),
|
||||||
'cost': fields.float('Cost',readonly=True, digits_compute=dp.get_precision('Account')),
|
'date_current': fields.date('Current date', required=True),
|
||||||
'quantity': fields.float('Time',readonly=True),
|
'state' : fields.selection([
|
||||||
|
('new', 'New'),
|
||||||
|
('draft','Draft'),
|
||||||
|
('confirm','Confirmed'),
|
||||||
|
('done','Done')], 'Status', readonly=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def init(self, cr):
|
def _select(self):
|
||||||
tools.drop_view_if_exists(cr, 'hr_timesheet_report')
|
return super(hr_timesheet_report, self)._select() + """,
|
||||||
cr.execute("""
|
htss.name,
|
||||||
create or replace view hr_timesheet_report as (
|
htss.date_from,
|
||||||
select
|
htss.date_to,
|
||||||
min(t.id) as id,
|
count(*) as nbr,
|
||||||
l.date as date,
|
(SELECT sum(day.total_difference)
|
||||||
sum(l.amount) as cost,
|
FROM hr_timesheet_sheet_sheet AS sheet
|
||||||
sum(l.unit_amount) as quantity,
|
LEFT JOIN hr_timesheet_sheet_sheet_day AS day
|
||||||
l.account_id as account_id,
|
ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_diff,
|
||||||
l.journal_id as journal_id,
|
(SELECT sum(day.total_timesheet)
|
||||||
l.product_id as product_id,
|
FROM hr_timesheet_sheet_sheet AS sheet
|
||||||
l.general_account_id as general_account_id,
|
LEFT JOIN hr_timesheet_sheet_sheet_day AS day
|
||||||
l.user_id as user_id,
|
ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_timesheet,
|
||||||
l.company_id as company_id,
|
(SELECT sum(day.total_attendance)
|
||||||
l.currency_id as currency_id
|
FROM hr_timesheet_sheet_sheet AS sheet
|
||||||
from
|
LEFT JOIN hr_timesheet_sheet_sheet_day AS day
|
||||||
hr_analytic_timesheet as t
|
ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_attendance,
|
||||||
left join account_analytic_line as l ON (t.line_id=l.id)
|
aal.to_invoice,
|
||||||
group by
|
htss.department_id,
|
||||||
l.date,
|
htss.state"""
|
||||||
l.account_id,
|
|
||||||
l.product_id,
|
def _from(self):
|
||||||
l.general_account_id,
|
return super(hr_timesheet_report, self)._from() + "left join hr_timesheet_sheet_sheet as htss ON (hat.sheet_id=htss.id)"
|
||||||
l.journal_id,
|
|
||||||
l.user_id,
|
def _group_by(self):
|
||||||
l.company_id,
|
return super(hr_timesheet_report, self)._group_by() + """,
|
||||||
l.currency_id
|
htss.date_from,
|
||||||
)
|
htss.date_to,
|
||||||
""")
|
aal.unit_amount,
|
||||||
|
aal.amount,
|
||||||
|
aal.to_invoice,
|
||||||
|
htss.name,
|
||||||
|
htss.state,
|
||||||
|
htss.id,
|
||||||
|
htss.department_id"""
|
||||||
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -1,65 +1,49 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
<record id="view_hr_timesheet_report_graph" model="ir.ui.view">
|
<record id="view_timesheet_report_graph" model="ir.ui.view">
|
||||||
<field name="name">hr.timesheet.report.graph</field>
|
<field name="name">timesheet.report.graph</field>
|
||||||
<field name="model">hr.timesheet.report</field>
|
<field name="model">hr.timesheet.report</field>
|
||||||
|
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_report_graph"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<graph string="Timesheet" type="pivot">
|
<field name="user_id" position="after">
|
||||||
<field name="user_id" type="row"/>
|
<field name="state" type="row"/>
|
||||||
<field name="date" interval="day" type="col"/>
|
</field>
|
||||||
<field name="quantity" type="measure"/>
|
<field name="cost" position="after">
|
||||||
<field name="cost" type="measure"/>
|
<field name="total_diff" type="measure"/>
|
||||||
</graph>
|
<field name="total_timesheet" type="measure"/>
|
||||||
|
<field name="total_attendance" type="measure"/>
|
||||||
</field>
|
</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="arch" type="xml">
|
|
||||||
<search string="Timesheet">
|
|
||||||
<filter icon="terp-go-year" string="This Month" name="month" domain="[('date','<=', time.strftime('%Y-%m-%d')),('date','>=',time.strftime('%Y-%m-01'))]" help="month"/>
|
|
||||||
<field name="account_id" groups="analytic.group_analytic_accounting"/>
|
|
||||||
<field name="user_id"/>
|
|
||||||
<group expand="0" string="Extended Filters...">
|
|
||||||
<field name="general_account_id"/>
|
|
||||||
<field name="product_id"/>
|
|
||||||
<field name="journal_id"/>
|
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
|
||||||
<field name="date" />
|
|
||||||
</group>
|
|
||||||
<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'}"/>
|
|
||||||
<filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'account_id'}" groups="analytic.group_analytic_accounting"/>
|
|
||||||
<filter string="General Account" icon="terp-folder-orange" context="{'group_by':'general_account_id'}"/>
|
|
||||||
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
|
||||||
<filter string="Date (day)" context="{'group_by':'date:day'}" help="Group by day of date"/>
|
|
||||||
<filter string="Date (month)" context="{'group_by':'date:month'}" help="Group by month of date"/>
|
|
||||||
<filter string="Date (year)" context="{'group_by':'date:year'}" help="Group by year of date"/>
|
|
||||||
</group>
|
|
||||||
</search>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_hr_timesheet_report_stat_all" model="ir.actions.act_window">
|
<record id="view_timesheet_report_search" model="ir.ui.view">
|
||||||
<field name="name">Timesheet Analysis</field>
|
<field name="name">timesheet.report.search</field>
|
||||||
<field name="res_model">hr.timesheet.report</field>
|
<field name="model">hr.timesheet.report</field>
|
||||||
<field name="view_type">form</field>
|
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_report_search"/>
|
||||||
<field name="view_mode">graph</field>
|
<field name="arch" type="xml">
|
||||||
<field name="context">{'search_default_month':1,'search_default_group_user_id':1,'group_by_no_leaf':1,'group_by':[]}</field>
|
<field name="account_id" position="before">
|
||||||
<field name="help" type="html">
|
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]"/>
|
||||||
<p>
|
<filter icon="terp-camera_test" string="Confirmed" domain="[('state','=','confirm')]"/>
|
||||||
This report performs analysis on timesheets created by your
|
<filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]"/>
|
||||||
human resources in the system. It allows you to have a full
|
</field>
|
||||||
overview of entries done by your employees. You can group them
|
<field name="general_account_id" position="after">
|
||||||
by specific selection criteria thanks to the search tool.
|
<field name="to_invoice"/>
|
||||||
</p>
|
<field name="department_id"/>
|
||||||
|
<field name="date_to"/>
|
||||||
|
<field name="date_from"/>
|
||||||
|
</field>
|
||||||
|
<filter name="product" position="before">
|
||||||
|
<filter string="Department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
|
||||||
|
</filter>
|
||||||
|
<filter name="analytic_account" position="before">
|
||||||
|
<filter string="Type of Invoicing" icon="terp-stock_symbol-selection" context="{'group_by':'to_invoice'}"/>
|
||||||
|
</filter>
|
||||||
|
<filter name="general_account" position="after">
|
||||||
|
<filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
|
||||||
|
</filter>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem
|
|
||||||
action="action_hr_timesheet_report_stat_all"
|
|
||||||
id="menu_hr_timesheet_report_all"
|
|
||||||
parent="hr.menu_hr_reporting" sequence="3"/>
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -1,118 +0,0 @@
|
||||||
# -*- 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/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
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:
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?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="arch" type="xml">
|
|
||||||
<graph string="Timesheet" type="pivot" stacked="True">
|
|
||||||
<field name="user_id" type="row"/>
|
|
||||||
<field name="state" type="row"/>
|
|
||||||
<field name="quantity" type="measure"/>
|
|
||||||
<field name="cost" type="measure"/>
|
|
||||||
<field name="total_diff" type="measure"/>
|
|
||||||
<field name="total_timesheet" type="measure"/>
|
|
||||||
<field name="total_attendance" type="measure"/>
|
|
||||||
</graph>
|
|
||||||
</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="arch" type="xml">
|
|
||||||
<search string="Timesheet">
|
|
||||||
<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')]"/>
|
|
||||||
<field name="account_id"/>
|
|
||||||
<field name="user_id" />
|
|
||||||
<group expand="0" string="Extended Filters...">
|
|
||||||
<field name="general_account_id"/>
|
|
||||||
<field name="to_invoice"/>
|
|
||||||
<field name="product_id"/>
|
|
||||||
<field name="department_id"/>
|
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
|
||||||
<field name="date_to"/>
|
|
||||||
<field name="date_from"/>
|
|
||||||
</group>
|
|
||||||
<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'}"/>
|
|
||||||
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
|
||||||
<filter string="Type of Invoicing" icon="terp-stock_symbol-selection" context="{'group_by':'to_invoice'}"/>
|
|
||||||
<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'}"/>
|
|
||||||
<filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
|
|
||||||
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
|
||||||
<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">graph</field>
|
|
||||||
<field name="context">{'search_default_year':1,'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.menu_hr_reporting" sequence="4" groups="base.group_hr_manager"/>
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
|
@ -6,4 +6,3 @@ access_hr_timesheet_sheet_sheet_account,hr_timesheet_sheet.sheet.account,model_h
|
||||||
access_hr_timesheet_report,hr.timesheet.report,model_hr_timesheet_report,base.group_hr_manager,1,1,0,0
|
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_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_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
|
|
||||||
|
|
|
Loading…
Reference in New Issue