Skip to content

Commit

Permalink
[IMP] hr_utilization_report: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mymage committed May 24, 2024
1 parent bc439e4 commit cc43f2e
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 54 deletions.
12 changes: 6 additions & 6 deletions hr_utilization_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Task Logs Utilization Report
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:15c20df740852c47e152f80c81c739c7bea280ef32b2bdf55abbe540d5cc7300
!! source digest: sha256:56b8e3ee58b006d2f5439dc625a95b84ee535fbc8297516fc7f14722575467fb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Task Logs Utilization Report
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
:target: https://github.com/OCA/timesheet/tree/14.0/hr_utilization_report
:target: https://github.com/OCA/timesheet/tree/16.0/hr_utilization_report
:alt: OCA/timesheet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_utilization_report
:target: https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_utilization_report
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -88,7 +88,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_utilization_report%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/timesheet/issues/new?body=module:%20hr_utilization_report%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -121,6 +121,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/14.0/hr_utilization_report>`_ project on GitHub.
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/16.0/hr_utilization_report>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion hr_utilization_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Task Logs Utilization Report",
"version": "14.0.1.0.3",
"version": "16.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/timesheet",
"author": "CorporateHub, " "Odoo Community Association (OCA)",
Expand Down
21 changes: 5 additions & 16 deletions hr_utilization_report/report/hr_utilization_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class HrUtilizationReport(models.TransientModel):
required=True,
)
only_active_employees = fields.Boolean(
string="Only Active Employees",
default=True,
)
employee_ids = fields.Many2many(
Expand Down Expand Up @@ -84,7 +83,6 @@ class HrUtilizationReport(models.TransientModel):
store=True,
)
total_capacity = fields.Float(
string="Total Capacity",
compute="_compute_total_capacity",
store=True,
)
Expand Down Expand Up @@ -292,7 +290,7 @@ def get_action(self, report_type="qweb-html"):
self.ensure_one()

if report_type not in self._supported_report_types():
raise UserError(_('"%s" report type is not supported' % (report_type)))
raise UserError(_('"%s" report type is not supported') % report_type)

report_name = "hr_utilization_report.report"

Expand All @@ -306,11 +304,12 @@ def get_action(self, report_type="qweb-html"):
)
if not action:
raise UserError(
_('"%s" report with "%s" type not found' % (report_name, report_type))
_('"%(report_name)s" report with "%(report_type)s" type not found')
% (report_name, report_type)
)

context = dict(self.env.context)
return action.with_context(context).report_action(self)
return action.with_context(**context).report_action(self)


class HrUtilizationReportAbstractField(models.AbstractModel):
Expand All @@ -325,7 +324,6 @@ class HrUtilizationReportAbstractField(models.AbstractModel):
ondelete="cascade",
)
sequence = fields.Integer(
string="Sequence",
required=True,
)
field_name = fields.Char(
Expand All @@ -340,9 +338,7 @@ class HrUtilizationReportAbstractField(models.AbstractModel):
string="Field type",
required=True,
)
aggregation = fields.Char(
string="Aggregation",
)
aggregation = fields.Char()
groupby = fields.Char(
string="Group-by expression",
compute="_compute_groupby",
Expand Down Expand Up @@ -404,11 +400,9 @@ class HrUtilizationReportGroup(models.TransientModel):
ondelete="cascade",
)
sequence = fields.Integer(
string="Sequence",
required=True,
)
scope = fields.Char(
string="Scope",
required=True,
)
name = fields.Char()
Expand All @@ -425,7 +419,6 @@ class HrUtilizationReportGroup(models.TransientModel):
store=True,
)
total_capacity = fields.Float(
string="Total Capacity",
compute="_compute_total_capacity",
store=True,
)
Expand Down Expand Up @@ -516,7 +509,6 @@ class HrUtilizationReportBlock(models.TransientModel):
ondelete="cascade",
)
sequence = fields.Integer(
string="Sequence",
required=True,
)
employee_id = fields.Many2one(
Expand All @@ -537,7 +529,6 @@ class HrUtilizationReportBlock(models.TransientModel):
store=True,
)
capacity = fields.Float(
string="Capacity",
compute="_compute_capacity",
store=True,
)
Expand Down Expand Up @@ -683,11 +674,9 @@ class HrUtilizationReportEntry(models.TransientModel):
ondelete="cascade",
)
sequence = fields.Integer(
string="Sequence",
required=True,
)
scope = fields.Char(
string="Scope",
required=True,
)
any_line_id = fields.Many2one(
Expand Down
28 changes: 14 additions & 14 deletions hr_utilization_report/report/hr_utilization_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<t t-call="hr_utilization_report.report_capacity">
<t t-set="capacity_value" t-value="report.total_capacity" />
</t>
<span t-esc="uom_hour.name" />
<span t-out="uom_hour.name" />
</span>
</h2>
</div>
Expand Down Expand Up @@ -145,16 +145,16 @@
<span>
<t
t-if="report.split_by_field_name"
t-esc="'%s (Yes / No), ' % (report.split_by_field_title)"
t-out="'%s (Yes / No), ' % (report.split_by_field_title)"
/>
<t t-else="">Utilization,</t>
<t t-if="report.utilization_format == 'percentage'">%</t>
<t t-else="" t-esc="uom_hour.name" />
<t t-else="" t-out="uom_hour.name" />
</span>
</th>
<th class="text-right">
<span>Capacity,
<t t-esc="uom_hour.name" />
<t t-out="uom_hour.name" />
</span>
</th>
</tr>
Expand All @@ -168,15 +168,15 @@
t-att-rowspan="len(block.entry_ids)"
style="vertical-align: middle;"
>
<span t-esc="block.employee_id.name" />
<span t-out="block.employee_id.name" />
</td>
</t>
<t t-elif="field.field_name != 'employee_id'">
<td>
<!-- see https://github.com/odoo/odoo/issues/29658 -->
<span
t-att-class="field.cell_classes"
t-raw="entry.render_value(field.field_name)"
t-out="entry.render_value(field.field_name)"
/>
</td>
</t>
Expand Down Expand Up @@ -246,7 +246,7 @@
<t t-foreach="report.entry_field_ids" t-as="field">
<t t-if="field.field_name == 'employee_id'">
<td>
<span t-esc="block.employee_id.name" />
<span t-out="block.employee_id.name" />
</td>
</t>
<t t-else="">
Expand Down Expand Up @@ -334,24 +334,24 @@
<template id="report_utilization">
<span t-if="report.utilization_format == 'percentage'">
<t
t-esc="utilization_value * 100.0"
t-out="utilization_value * 100.0"
t-options="{'widget': 'float', 'precision': 1}"
/>%
</span>
<t t-elif="report.utilization_format == 'absolute'">
<span
t-if="report.time_format == 'hh_mm'"
t-esc="amount_value"
t-out="amount_value"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"
/>
<span
t-elif="report.time_format == 'hh_mm_ss'"
t-esc="amount_value"
t-out="amount_value"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour'}"
/>
<span
t-elif="report.time_format == 'decimal'"
t-esc="amount_value"
t-out="amount_value"
t-options="{'widget': 'float', 'precision': 2}"
/>
</t>
Expand All @@ -360,17 +360,17 @@
<template id="report_capacity">
<span
t-if="report.time_format == 'hh_mm'"
t-esc="capacity_value"
t-out="capacity_value"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour', 'round': 'minute'}"
/>
<span
t-elif="report.time_format == 'hh_mm_ss'"
t-esc="capacity_value"
t-out="capacity_value"
t-options="{'widget': 'duration', 'digital': True, 'unit': 'hour'}"
/>
<span
t-elif="report.time_format == 'decimal'"
t-esc="capacity_value"
t-out="capacity_value"
t-options="{'widget': 'float', 'precision': 2}"
/>
</template>
Expand Down
9 changes: 5 additions & 4 deletions hr_utilization_report/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -366,9 +367,9 @@ <h1 class="title">Task Logs Utilization Report</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:15c20df740852c47e152f80c81c739c7bea280ef32b2bdf55abbe540d5cc7300
!! source digest: sha256:56b8e3ee58b006d2f5439dc625a95b84ee535fbc8297516fc7f14722575467fb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/14.0/hr_utilization_report"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_utilization_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/timesheet/tree/16.0/hr_utilization_report"><img alt="OCA/timesheet" src="https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_utilization_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/timesheet&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to generate Utilization Report from Task Logs.</p>
<dl class="docutils">
<dt>Features:</dt>
Expand Down Expand Up @@ -439,7 +440,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/timesheet/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20hr_utilization_report%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20hr_utilization_report%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -467,7 +468,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/14.0/hr_utilization_report">OCA/timesheet</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/16.0/hr_utilization_report">OCA/timesheet</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions hr_utilization_report/tests/test_hr_utilization_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_2(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_qweb_html(report.ids)
)._render_qweb_html(report.ids, None, self.wednesday)

def test_3(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_4(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_5(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -284,7 +284,7 @@ def test_5(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_6(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -339,7 +339,7 @@ def test_6(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_7(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -394,7 +394,7 @@ def test_7(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_8(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -545,7 +545,7 @@ def test_10(self):
)

self.assertIn(
"group_id",
"plan_id",
map(lambda x: x[0], self.Wizard._selection_split_by_field_name()),
)

Expand All @@ -562,7 +562,7 @@ def test_10(self):
],
)
],
"split_by_field_name": "group_id",
"split_by_field_name": "plan_id",
"utilization_format": "percentage",
}
)
Expand All @@ -571,7 +571,7 @@ def test_10(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_11(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -620,7 +620,7 @@ def test_11(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)

def test_12(self):
project = self.SudoProject.create(
Expand Down Expand Up @@ -663,7 +663,7 @@ def test_12(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.saturday)

def test_entry_with_no_task(self):
"""Test empty data (task is empty)"""
Expand Down Expand Up @@ -734,4 +734,4 @@ def test_entry_with_no_task(self):
report = self.Report.create(wizard._collect_report_values())
self.IrActionReport._get_report_from_name(
"hr_utilization_report.report"
)._render_xlsx(report.ids, None)
)._render_xlsx(report.ids, None, self.wednesday)
Loading

0 comments on commit cc43f2e

Please sign in to comment.