diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_timesheet/report | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_timesheet/report')
| -rw-r--r-- | addons/hr_timesheet/report/__init__.py | 1 | ||||
| -rw-r--r-- | addons/hr_timesheet/report/hr_timesheet_report_view.xml | 164 | ||||
| -rw-r--r-- | addons/hr_timesheet/report/project_report.py | 28 | ||||
| -rw-r--r-- | addons/hr_timesheet/report/project_report_view.xml | 18 | ||||
| -rw-r--r-- | addons/hr_timesheet/report/report_timesheet_templates.xml | 96 |
5 files changed, 307 insertions, 0 deletions
diff --git a/addons/hr_timesheet/report/__init__.py b/addons/hr_timesheet/report/__init__.py new file mode 100644 index 00000000..e56203fb --- /dev/null +++ b/addons/hr_timesheet/report/__init__.py @@ -0,0 +1 @@ +from . import project_report 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 00000000..1ae8aa59 --- /dev/null +++ b/addons/hr_timesheet/report/hr_timesheet_report_view.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + <record id="act_hr_timesheet_report" model="ir.actions.act_window"> + <field name="name">Timesheets By Employee</field> + <field name="res_model">account.analytic.line</field> + <field name="domain">[('project_id', '!=', False)]</field> + <field name="context">{'search_default_groupby_employee':1,}</field> + <field name="search_view_id" ref="hr_timesheet_line_search"/> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + No activities found. + </p><p> + Track your working hours by projects every day and invoice this time to your customers. + </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.view_hr_timesheet_line_pivot"/> + <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.view_hr_timesheet_line_graph"/> + <field name="act_window_id" ref="act_hr_timesheet_report"/> + </record> + + <record model="ir.actions.act_window.view" id="act_hr_timesheet_report_tree"> + <field name="sequence" eval="10"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_tree"/> + <field name="act_window_id" ref="act_hr_timesheet_report"/> + </record> + + <record model="ir.actions.act_window.view" id="act_hr_timesheet_report_form"> + <field name="sequence" eval="15"/> + <field name="view_mode">form</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_form"/> + <field name="act_window_id" ref="act_hr_timesheet_report"/> + </record> + + <record id="timesheet_action_report_by_project" model="ir.actions.act_window"> + <field name="name">Timesheets By Project</field> + <field name="res_model">account.analytic.line</field> + <field name="domain">[('project_id', '!=', False)]</field> + <field name="context">{'search_default_groupby_project': 1}</field> + <field name="search_view_id" ref="hr_timesheet_line_search"/> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + No activities found. + </p><p> + Track your working hours by projects every day and invoice this time to your customers. + </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.view_hr_timesheet_line_pivot"/> + <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.view_hr_timesheet_line_graph"/> + <field name="act_window_id" ref="timesheet_action_report_by_project"/> + </record> + + <record id="timesheet_action_view_report_by_project_tree" model="ir.actions.act_window.view"> + <field name="sequence" eval="10"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_tree"/> + <field name="act_window_id" ref="timesheet_action_report_by_project"/> + </record> + + <record id="timesheet_action_view_report_by_project_form" model="ir.actions.act_window.view"> + <field name="sequence" eval="15"/> + <field name="view_mode">form</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_form"/> + <field name="act_window_id" ref="timesheet_action_report_by_project"/> + </record> + + <record id="timesheet_action_report_by_task" model="ir.actions.act_window"> + <field name="name">Timesheets By Task</field> + <field name="res_model">account.analytic.line</field> + <field name="domain">[('project_id', '!=', False)]</field> + <field name="context">{'search_default_groupby_project':1,'search_default_groupby_task':1,}</field> + <field name="search_view_id" ref="hr_timesheet_line_search"/> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + No activities found. + </p><p> + Track your working hours by projects every day and invoice this time to your customers. + </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.view_hr_timesheet_line_pivot"/> + <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.view_hr_timesheet_line_graph"/> + <field name="act_window_id" ref="timesheet_action_report_by_task"/> + </record> + + <record id="timesheet_action_view_report_by_task_tree" model="ir.actions.act_window.view"> + <field name="sequence" eval="10"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_tree"/> + <field name="act_window_id" ref="timesheet_action_report_by_task"/> + </record> + + <record id="timesheet_action_view_report_by_task_form" model="ir.actions.act_window.view"> + <field name="sequence" eval="15"/> + <field name="view_mode">form</field> + <field name="view_id" ref="hr_timesheet.hr_timesheet_line_form"/> + <field name="act_window_id" ref="timesheet_action_report_by_task"/> + </record> + + <menuitem id="menu_timesheets_reports" + name="Reporting" + parent="timesheet_menu_root" + groups="hr_timesheet.group_timesheet_manager" + sequence="99"/> + + <menuitem id="menu_timesheets_reports_timesheet" + name="Timesheets" + parent="menu_timesheets_reports" + groups="hr_timesheet.group_timesheet_manager" + sequence="10"/> + + <menuitem id="menu_hr_activity_analysis" + parent="menu_timesheets_reports_timesheet" + action="act_hr_timesheet_report" + 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> diff --git a/addons/hr_timesheet/report/project_report.py b/addons/hr_timesheet/report/project_report.py new file mode 100644 index 00000000..85a5e433 --- /dev/null +++ b/addons/hr_timesheet/report/project_report.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +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) + + def _select(self): + return super(ReportProjectTaskUser, self)._select() + """, + progress as progress, + t.effective_hours as hours_effective, + t.planned_hours - t.effective_hours - t.subtask_effective_hours as remaining_hours, + planned_hours as hours_planned""" + + def _group_by(self): + return super(ReportProjectTaskUser, self)._group_by() + """, + remaining_hours, + t.effective_hours, + progress, + planned_hours + """ diff --git a/addons/hr_timesheet/report/project_report_view.xml b/addons/hr_timesheet/report/project_report_view.xml new file mode 100644 index 00000000..d62fb501 --- /dev/null +++ b/addons/hr_timesheet/report/project_report_view.xml @@ -0,0 +1,18 @@ +<?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"> + <graph string="Tasks Analysis" type="bar" sample="1" disable_linking="1"> + <field name="project_id" position="after"> + <field name="hours_planned" type="measure"/> + <field name="remaining_hours" type="measure"/> + </field> + </graph> + </field> + </record> + </data> +</odoo> diff --git a/addons/hr_timesheet/report/report_timesheet_templates.xml b/addons/hr_timesheet/report/report_timesheet_templates.xml new file mode 100644 index 00000000..1e74abae --- /dev/null +++ b/addons/hr_timesheet/report/report_timesheet_templates.xml @@ -0,0 +1,96 @@ +<odoo> + <template id="report_timesheet"> + <t t-call="web.html_container"> + <t t-call="web.external_layout"> + <t t-set="company" t-value="docs.mapped('project_id')[0].company_id if len(docs.mapped('project_id')) == 1 else docs.env.company"/> + <t t-set="show_task" t-value="bool(docs.mapped('task_id'))"/> + <t t-set="show_project" t-value="len(docs.mapped('project_id')) > 1"/> + <div class="page"> + <div class="oe_structure"/> + <div class="row" style="margin-top:10px;"> + <div class="col-lg-12"> + <h2> + <span>Timesheet Entries + <t t-if="len(docs.mapped('project_id')) == 1"> + for the <t t-esc="docs.mapped('project_id')[0].name"/> Project + </t> + </span> + </h2> + </div> + </div> + + <div class="row" style="margin-top:10px;"> + <div class="col-lg-12"> + <t t-set='is_uom_day' t-value='docs._is_timesheet_encode_uom_day()'/> + <table class="table table-sm"> + <thead> + <tr> + <th class="align-middle"><span>Date</span></th> + <th class="align-middle"><span>Responsible</span></th> + <th class="align-middle"><span>Description</span></th> + <th class="align-middle" t-if="show_project"><span>Project</span></th> + <th class="align-middle" t-if="show_task"><span>Task</span></th> + <th class="text-right"> + <span t-if="is_uom_day">Time Spent (Days)</span> + <span t-else="">Time Spent (Hours)</span> + </th> + </tr> + </thead> + <tbody> + <tr t-foreach="docs" t-as="l"> + <td> + <span t-field="l.date"/> + </td> + <td> + <span t-field="l.user_id.partner_id.name"/> + <span t-if="not l.user_id.partner_id.name" t-field="l.employee_id"/> + </td> + <td > + <span t-field="l.name" t-options="{'widget': 'text'}"/> + </td> + <td t-if="show_project"> + <span t-field="l.project_id.sudo().name"/> + </td> + <td t-if="show_task"> + <t t-if="l.task_id"><span t-field="l.task_id.sudo().name"/></t> + </td> + <td class="text-right"> + <span t-if="is_uom_day" t-esc="l._get_timesheet_time_day()" t-options="{'widget': 'timesheet_uom'}"/> + <span t-else="" t-field="l.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-right" t-attf-colspan="{{nbCols}}"> + <strong t-if="is_uom_day"> + <span style="margin-right: 15px;">Total (Days)</span> + <t t-esc="docs._convert_hours_to_days(sum(docs.mapped('unit_amount')))" t-options="{'widget': 'timesheet_uom'}"/> + </strong> + <strong t-else=""> + <span style="margin-right: 15px;">Total (Hours)</span> + <t t-esc="sum(docs.mapped('unit_amount'))" t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"/> + </strong> + </td> + </tr> + </tbody> + </table> + </div> + </div> + <div class="oe_structure"/> + </div> + </t> + </t> + </template> + + <record id="timesheet_report" model="ir.actions.report"> + <field name="name">Timesheet Entries</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> +</odoo> |
