mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-26 21:32:00 +02:00
Initial commit: Hr packages
This commit is contained in:
commit
62531cd146
2820 changed files with 1432848 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import project_report
|
||||
from . import timesheets_analysis_report
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="timesheets_analysis_report_pivot_employee" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.pivot</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Timesheets Analysis" sample="1" disable_linking="True">
|
||||
<field name="employee_id" type="row"/>
|
||||
<field name="date" interval="month" type="col"/>
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheets_analysis_report_graph_employee" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.graph</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview" disable_linking="True">
|
||||
<field name="employee_id" type="row"/>
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheets_analysis_report_pivot_project" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.pivot</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Timesheets Analysis" sample="1" disable_linking="True">
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="date" interval="month" type="col"/>
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheets_analysis_report_graph_project" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.graph</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview" disable_linking="True">
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheets_analysis_report_pivot_task" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.pivot</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Timesheets Analysis" sample="1" disable_linking="True">
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="task_id" type="row"/>
|
||||
<field name="date" interval="month" type="col"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheets_analysis_report_graph_task" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.graph</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Timesheets" sample="1" js_class="hr_timesheet_graphview" disable_linking="True">
|
||||
<field name="project_id" type="row"/>
|
||||
<field name="task_id" type="row"/>
|
||||
<field name="amount" string="Timesheet Costs"/>
|
||||
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_timesheet_report_search" model="ir.ui.view">
|
||||
<field name="name">timesheets.analysis.report.search</field>
|
||||
<field name="model">timesheets.analysis.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Timesheet">
|
||||
<field name="date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="project_id"/>
|
||||
<field name="ancestor_task_id" groups="project.group_subtask_project"/>
|
||||
<field name="task_id"/>
|
||||
<field name="name"/>
|
||||
<field name="department_id"/>
|
||||
<field name="manager_id"/>
|
||||
<filter name="mine" string="My Timesheets" domain="[('user_id', '=', uid)]"/>
|
||||
<separator/>
|
||||
<filter name="month" string="Date" date="date"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Project" name="groupby_project" domain="[]" context="{'group_by': 'project_id'}"/>
|
||||
<filter string="Ancestor Task" name="groupby_parent_task" domain="[]" context="{'group_by': 'ancestor_task_id'}" groups="project.group_subtask_project"/>
|
||||
<filter string="Task" name="groupby_task" domain="[]" context="{'group_by': 'task_id'}"/>
|
||||
<filter string="Date" name="groupby_date" domain="[]" context="{'group_by': 'date'}" help="Timesheet by Date"/>
|
||||
<filter string="Department" name="groupby_department" domain="[]" context="{'group_by': 'department_id'}"/>
|
||||
<filter string="Manager" name="groupby_manager" domain="[]" context="{'group_by': 'manager_id'}"/>
|
||||
<filter string="Employee" name="groupby_employee" domain="[]" context="{'group_by': 'employee_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Group by employee -->
|
||||
<record id="act_hr_timesheet_report" model="ir.actions.act_window">
|
||||
<field name="name">Timesheets by Employee</field>
|
||||
<field name="res_model">timesheets.analysis.report</field>
|
||||
<field name="domain">[('project_id', '!=', False)]</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_timesheet_report_search"/>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_empty_folder">
|
||||
No data yet!
|
||||
</p><p>
|
||||
Analyze the projects and tasks on which your employees spend their time.<br/>
|
||||
Evaluate which part is billable and what costs it represents.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="act_hr_timesheet_report_pivot">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">pivot</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_employee"/>
|
||||
<field name="act_window_id" ref="act_hr_timesheet_report"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_report_by_employee_graph" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="6"/>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_employee"/>
|
||||
<field name="act_window_id" ref="act_hr_timesheet_report"/>
|
||||
</record>
|
||||
|
||||
<!-- Group by project-->
|
||||
<record id="timesheet_action_report_by_project" model="ir.actions.act_window">
|
||||
<field name="name">Timesheets by Project</field>
|
||||
<field name="res_model">timesheets.analysis.report</field>
|
||||
<field name="domain">[('project_id', '!=', False)]</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_timesheet_report_search"/>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_empty_folder">
|
||||
No data yet!
|
||||
</p><p>
|
||||
Analyze the projects and tasks on which your employees spend their time.<br/>
|
||||
Evaluate which part is billable and what costs it represents.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_report_by_project_pivot" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">pivot</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_project"/>
|
||||
<field name="act_window_id" ref="timesheet_action_report_by_project"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_report_by_project_graph" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="6"/>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_project"/>
|
||||
<field name="act_window_id" ref="timesheet_action_report_by_project"/>
|
||||
</record>
|
||||
|
||||
<!-- Group by task -->
|
||||
<record id="timesheet_action_report_by_task" model="ir.actions.act_window">
|
||||
<field name="name">Timesheets by Task</field>
|
||||
<field name="res_model">timesheets.analysis.report</field>
|
||||
<field name="domain">[('project_id', '!=', False)]</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="search_view_id" ref="hr_timesheet_report_search"/>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_empty_folder">
|
||||
No data yet!
|
||||
</p><p>
|
||||
Analyze the projects and tasks on which your employees spend their time.<br/>
|
||||
Evaluate which part is billable and what costs it represents.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_report_by_task_pivot" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">pivot</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_pivot_task"/>
|
||||
<field name="act_window_id" ref="timesheet_action_report_by_task"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_report_by_task_graph" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="6"/>
|
||||
<field name="view_mode">graph</field>
|
||||
<field name="view_id" ref="hr_timesheet.timesheets_analysis_report_graph_task"/>
|
||||
<field name="act_window_id" ref="timesheet_action_report_by_task"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_timesheets_reports"
|
||||
name="Reporting"
|
||||
parent="timesheet_menu_root"
|
||||
sequence="99"/>
|
||||
|
||||
<menuitem id="menu_timesheets_reports_timesheet"
|
||||
name="Timesheets"
|
||||
parent="menu_timesheets_reports"
|
||||
sequence="10"/>
|
||||
|
||||
<menuitem id="menu_hr_activity_analysis"
|
||||
parent="menu_timesheets_reports_timesheet"
|
||||
action="act_hr_timesheet_report"
|
||||
groups="hr_timesheet.group_hr_timesheet_approver"
|
||||
name="By Employee"
|
||||
sequence="10"/>
|
||||
|
||||
<menuitem id="timesheet_menu_report_timesheet_by_project"
|
||||
parent="menu_timesheets_reports_timesheet"
|
||||
action="timesheet_action_report_by_project"
|
||||
name="By Project"
|
||||
sequence="15"/>
|
||||
|
||||
<menuitem id="timesheet_menu_report_timesheet_by_task"
|
||||
parent="menu_timesheets_reports_timesheet"
|
||||
action="timesheet_action_report_by_task"
|
||||
name="By Task"
|
||||
sequence="20"/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class ReportProjectTaskUser(models.Model):
|
||||
_inherit = "report.project.task.user"
|
||||
|
||||
hours_planned = fields.Float('Planned Hours', readonly=True)
|
||||
hours_effective = fields.Float('Effective Hours', readonly=True)
|
||||
remaining_hours = fields.Float('Remaining Hours', readonly=True)
|
||||
progress = fields.Float('Progress', group_operator='avg', readonly=True)
|
||||
overtime = fields.Float(readonly=True)
|
||||
|
||||
def _select(self):
|
||||
select_to_append = """,
|
||||
(t.effective_hours * 100) / NULLIF(t.planned_hours, 0) as progress,
|
||||
t.effective_hours as hours_effective,
|
||||
t.planned_hours - t.effective_hours - t.subtask_effective_hours as remaining_hours,
|
||||
NULLIF(t.planned_hours, 0) as hours_planned,
|
||||
t.overtime as overtime
|
||||
"""
|
||||
return super(ReportProjectTaskUser, self)._select() + select_to_append
|
||||
|
||||
def _group_by(self):
|
||||
group_by_append = """,
|
||||
t.effective_hours,
|
||||
t.subtask_effective_hours,
|
||||
t.planned_hours,
|
||||
t.overtime
|
||||
"""
|
||||
return super(ReportProjectTaskUser, self)._group_by() + group_by_append
|
||||
|
||||
@api.model
|
||||
def _get_view_cache_key(self, view_id=None, view_type='form', **options):
|
||||
"""The override of _get_view changing the time field labels according to the company timesheet encoding UOM
|
||||
makes the view cache dependent on the company timesheet encoding uom"""
|
||||
key = super()._get_view_cache_key(view_id, view_type, **options)
|
||||
return key + (self.env.company.timesheet_encode_uom_id,)
|
||||
|
||||
@api.model
|
||||
def _get_view(self, view_id=None, view_type='form', **options):
|
||||
arch, view = super()._get_view(view_id, view_type, **options)
|
||||
if view_type in ['pivot', 'graph'] and self.env.company.timesheet_encode_uom_id == self.env.ref('uom.product_uom_day'):
|
||||
arch = self.env['account.analytic.line']._apply_time_label(arch, related_model=self._name)
|
||||
return arch, view
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_task_project_user_graph_inherited" model="ir.ui.view">
|
||||
<field name="name">report.project.task.user.graph.inherited</field>
|
||||
<field name="model">report.project.task.user</field>
|
||||
<field name="inherit_id" ref="project.view_task_project_user_graph" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//graph" position="attributes">
|
||||
<attribute name="js_class">hr_timesheet_graphview</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='project_id']" position='after'>
|
||||
<field name="hours_planned" widget="timesheet_uom" type="measure"/>
|
||||
<field name="hours_effective" widget="timesheet_uom" type="measure"/>
|
||||
<field name="remaining_hours" widget="timesheet_uom" type="measure"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_task_project_user_pivot_inherited" model="ir.ui.view">
|
||||
<field name="name">report.project.task.user.pivot.inherited</field>
|
||||
<field name="model">report.project.task.user</field>
|
||||
<field name="inherit_id" ref="project.view_task_project_user_pivot"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='project_id']" position='after'>
|
||||
<field name="hours_planned" widget="timesheet_uom" type="measure"/>
|
||||
<field name="hours_effective" widget="timesheet_uom" type="measure"/>
|
||||
<field name="remaining_hours" widget="timesheet_uom" type="measure"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="report_project_task_user_view_search" model="ir.ui.view">
|
||||
<field name="name">report.project.task.user.view.search.inherit.hr.timesheet</field>
|
||||
<field name="model">report.project.task.user</field>
|
||||
<field name="inherit_id" ref="project.view_task_project_user_search" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='late']" position="after">
|
||||
<filter string="Tasks in Overtime" name="overtime" domain="[('overtime', '>', 0)]"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='my_favorite_projects']" position="after">
|
||||
<filter string="My Team's Projects" name="my_team_projects" domain="[('project_id.user_id.employee_id.parent_id.user_id', '=', uid), ('project_id.user_id', '!=', uid), ('user_ids', '!=', uid), ('user_ids', '!=', False)]"/>
|
||||
<filter string="My Department's Projects" name="my_department" domain="[('project_id.user_id.employee_id.member_of_department', '=', True)]"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='followed_by_me']" position="after">
|
||||
<filter string="My Team's Tasks" name="my_team_tasks" domain="[('user_ids.employee_id.parent_id.user_id', '=', uid)]" />
|
||||
<filter string="My Department's Tasks" name="my_department" domain="[('user_ids.employee_id.member_of_department', '=', True)]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="report_project_task_user_view_tree" model="ir.ui.view">
|
||||
<field name="name">report.project.task.user.view.tree.inherit.hr.timesheet</field>
|
||||
<field name="model">report.project.task.user</field>
|
||||
<field name="inherit_id" ref="project.report_project_task_user_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="user_ids" position="after">
|
||||
<field name="hours_effective" optional="hide" widget="float_time"/>
|
||||
<field name="progress" optional="hide" widget="progressbar"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="hr_timesheet.timesheet_table">
|
||||
<t t-set='is_uom_day' t-value='lines._is_timesheet_encode_uom_day()'/>
|
||||
<div class="row mt8">
|
||||
<div class="col-12">
|
||||
<table class="table table-sm">
|
||||
<thead style="display: table-row-group">
|
||||
<tr>
|
||||
<th class="text-start align-middle"><span>Date</span></th>
|
||||
<th class="text-start align-middle"><span>Employee</span></th>
|
||||
<th class="text-start align-middle" t-if="show_project"><span>Project</span></th>
|
||||
<th class="text-start align-middle" t-if="show_task"><span>Task</span></th>
|
||||
<th class="text-start align-middle"><span>Description</span></th>
|
||||
<th class="text-end">
|
||||
<span t-if="is_uom_day">Days Spent</span>
|
||||
<span t-else="">Hours Spent</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="lines" t-as="line" t-att-style="'background-color: #F1F1F1;' if line_index % 2 == 0 else ''">
|
||||
<td class="align-middle">
|
||||
<span t-field="line.date"/>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.user_id.partner_id.name"/>
|
||||
<span t-if="not line.user_id.partner_id.name" t-field="line.employee_id"/>
|
||||
</td>
|
||||
<td t-if="show_project" class="align-middle">
|
||||
<span t-field="line.project_id.sudo().name"/>
|
||||
</td>
|
||||
<td t-if="show_task" class="align-middle">
|
||||
<span t-if="line.task_id" t-field="line.task_id.sudo().name"/>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.name" t-options="{'widget': 'text'}"/>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
<span t-if="is_uom_day" t-esc="line._get_timesheet_time_day()" t-options="{'widget': 'timesheet_uom'}"/>
|
||||
<span t-else="" t-field="line.unit_amount" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<t t-set="nbCols" t-value="4"/>
|
||||
<t t-if="show_project" t-set="nbCols" t-value="nbCols + 1"/>
|
||||
<t t-if="show_task" t-set="nbCols" t-value="nbCols + 1"/>
|
||||
<td class="text-end" t-attf-colspan="{{nbCols}}">
|
||||
<strong t-if="is_uom_day">
|
||||
<span style="margin-right: 15px;">Total (Days)</span>
|
||||
<t t-esc="lines._convert_hours_to_days(sum(lines.mapped('unit_amount')))" t-options="{'widget': 'timesheet_uom'}"/>
|
||||
</strong>
|
||||
<strong t-else="">
|
||||
<span style="margin-right: 15px;">Total (Hours)</span>
|
||||
<t t-esc="sum(lines.mapped('unit_amount'))" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/>
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="hr_timesheet.timesheet_project_task_page">
|
||||
<t t-set="show_record" t-value="len(docs.ids) == 1"/>
|
||||
<t t-set="title" t-value="docs._description"/>
|
||||
<t t-set="company" t-value="docs.company_id if len(docs) == 1 else docs.env.company"/>
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.external_layout">
|
||||
<div class="page">
|
||||
<t t-foreach="docs" t-as="doc">
|
||||
<t t-if="from_project" t-set="show_task"
|
||||
t-value="bool(doc.timesheet_ids.task_id)"/>
|
||||
<div class="oe_structure"/>
|
||||
<div class="row mt8">
|
||||
<div class="col-12">
|
||||
<t t-if="doc.allow_timesheets and doc.timesheet_ids">
|
||||
<h1 class="my-4">
|
||||
<t t-if="not show_record">
|
||||
<t t-out="title"/>: <span t-field="doc.name"/>
|
||||
</t>
|
||||
</h1>
|
||||
<h2>
|
||||
<span>Timesheets
|
||||
<t t-if="show_record">
|
||||
for the <t t-out="doc.name"/> <t t-out="title"/>
|
||||
</t>
|
||||
</span>
|
||||
</h2>
|
||||
<t t-set='lines' t-value='doc.timesheet_ids'/>
|
||||
<t t-call="hr_timesheet.timesheet_table"/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="report_timesheet">
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.external_layout">
|
||||
<t t-set="company" t-value="docs.project_id.company_id if len(docs.project_id) == 1 else docs.env.company"/>
|
||||
<t t-set="show_task" t-value="bool(docs.task_id)"/>
|
||||
<t t-set="show_project" t-value="len(docs.project_id) > 1"/>
|
||||
<div class="page">
|
||||
<div class="oe_structure"/>
|
||||
<div class="row mt8">
|
||||
<div class="col-lg-12">
|
||||
<h2>
|
||||
<span>Timesheets
|
||||
<t t-if="len(docs.project_id) == 1">
|
||||
for the <t t-out="docs.project_id.name"/> Project
|
||||
</t>
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<t t-set='lines' t-value='docs'/>
|
||||
<t t-call="hr_timesheet.timesheet_table"/>
|
||||
<div class="oe_structure"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<!-- Project Task Timesheet Report for given timesheets -->
|
||||
<template id="report_timesheet_task">
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.external_layout">
|
||||
<t t-set="company" t-value="docs.project_id.company_id if len(docs.project_id) == 1 else docs.env.company"/>
|
||||
<t t-set="show_task" t-value="len(docs.task_id) > 1"/>
|
||||
<t t-set="show_project" t-value="False"/>
|
||||
<div class="page">
|
||||
<div class="oe_structure"/>
|
||||
<div class="row mt8">
|
||||
<div class="col-12">
|
||||
<h2>
|
||||
<span>Timesheets
|
||||
<t t-if="len(docs.task_id) == 1">
|
||||
for <t t-out="docs.task_id.name"/>
|
||||
</t>
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<t t-set='lines' t-value='docs'/>
|
||||
<t t-call="hr_timesheet.timesheet_table"/>
|
||||
<div class="oe_structure"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<record id="timesheet_report" model="ir.actions.report">
|
||||
<field name="name">Timesheets</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">hr_timesheet.report_timesheet</field>
|
||||
<field name="report_file">report_timesheet</field>
|
||||
<field name="binding_model_id" ref="model_account_analytic_line"/>
|
||||
<field name="binding_type">report</field>
|
||||
</record>
|
||||
|
||||
<!-- Project Task Timesheet Report -->
|
||||
<template id="report_project_task_timesheet">
|
||||
<t t-call="hr_timesheet.timesheet_project_task_page"/>
|
||||
</template>
|
||||
|
||||
<record id="timesheet_report_task" model="ir.actions.report">
|
||||
<field name="name">Timesheets</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">hr_timesheet.report_project_task_timesheet</field>
|
||||
<field name="report_file">report_timesheet_task</field>
|
||||
<field name="binding_model_id" ref="model_project_task"/>
|
||||
<field name="binding_type">report</field>
|
||||
</record>
|
||||
|
||||
<!-- Project Timesheet Report -->
|
||||
<template id="report_timesheet_project">
|
||||
<t t-set="from_project" t-value="True"/>
|
||||
<t t-call="hr_timesheet.timesheet_project_task_page"/>
|
||||
</template>
|
||||
|
||||
<record id="timesheet_report_project" model="ir.actions.report">
|
||||
<field name="name">Timesheets</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">hr_timesheet.report_timesheet_project</field>
|
||||
<field name="report_file">report_timesheet_project</field>
|
||||
<field name="binding_model_id" ref="model_project_project"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_report_task_timesheets" model="ir.actions.report">
|
||||
<field name="name">Timesheets</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">hr_timesheet.report_timesheet_task</field>
|
||||
<field name="report_file">report_timesheet</field>
|
||||
<field name="binding_type">report</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from psycopg2 import sql
|
||||
|
||||
from odoo import api, tools, fields, models
|
||||
|
||||
|
||||
class TimesheetsAnalysisReport(models.Model):
|
||||
_name = "timesheets.analysis.report"
|
||||
_description = "Timesheets Analysis Report"
|
||||
_auto = False
|
||||
|
||||
name = fields.Char("Description", readonly=True)
|
||||
user_id = fields.Many2one("res.users", string="User", readonly=True)
|
||||
project_id = fields.Many2one("project.project", string="Project", readonly=True)
|
||||
task_id = fields.Many2one("project.task", string="Task", readonly=True)
|
||||
ancestor_task_id = fields.Many2one("project.task", string="Ancestor Task", readonly=True)
|
||||
employee_id = fields.Many2one("hr.employee", string="Employee", readonly=True)
|
||||
manager_id = fields.Many2one("hr.employee", "Manager", readonly=True)
|
||||
company_id = fields.Many2one("res.company", string="Company", readonly=True)
|
||||
department_id = fields.Many2one("hr.department", string="Department", readonly=True)
|
||||
currency_id = fields.Many2one('res.currency', string="Currency", readonly=True)
|
||||
date = fields.Date("Date", readonly=True)
|
||||
amount = fields.Monetary("Amount", readonly=True)
|
||||
unit_amount = fields.Float("Hours Spent", readonly=True)
|
||||
|
||||
@property
|
||||
def _table_query(self):
|
||||
return "%s %s %s" % (self._select(), self._from(), self._where())
|
||||
|
||||
@api.model
|
||||
def _select(self):
|
||||
return """
|
||||
SELECT
|
||||
A.id AS id,
|
||||
A.name AS name,
|
||||
A.user_id AS user_id,
|
||||
A.project_id AS project_id,
|
||||
A.task_id AS task_id,
|
||||
A.ancestor_task_id AS ancestor_task_id,
|
||||
A.employee_id AS employee_id,
|
||||
A.manager_id AS manager_id,
|
||||
A.company_id AS company_id,
|
||||
A.department_id AS department_id,
|
||||
A.currency_id AS currency_id,
|
||||
A.date AS date,
|
||||
A.amount AS amount,
|
||||
A.unit_amount AS unit_amount
|
||||
"""
|
||||
|
||||
@api.model
|
||||
def _from(self):
|
||||
return "FROM account_analytic_line A"
|
||||
|
||||
@api.model
|
||||
def _where(self):
|
||||
return "WHERE A.project_id IS NOT NULL"
|
||||
|
||||
@api.model
|
||||
def _get_view_cache_key(self, view_id=None, view_type='form', **options):
|
||||
"""The override of _get_view changing the time field labels according to the company timesheet encoding UOM
|
||||
makes the view cache dependent on the company timesheet encoding uom"""
|
||||
key = super()._get_view_cache_key(view_id, view_type, **options)
|
||||
return key + (self.env.company.timesheet_encode_uom_id,)
|
||||
|
||||
@api.model
|
||||
def _get_view(self, view_id=None, view_type='form', **options):
|
||||
arch, view = super()._get_view(view_id, view_type, **options)
|
||||
if view_type in ["pivot", "graph"] and self.env.company.timesheet_encode_uom_id == self.env.ref("uom.product_uom_day"):
|
||||
arch = self.env["account.analytic.line"]._apply_time_label(arch, related_model=self._name)
|
||||
return arch, view
|
||||
|
||||
def init(self):
|
||||
tools.drop_view_if_exists(self.env.cr, self._table)
|
||||
self.env.cr.execute(
|
||||
sql.SQL("CREATE or REPLACE VIEW {} as ({})").format(
|
||||
sql.Identifier(self._table),
|
||||
sql.SQL(self._table_query)
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue