Skip to content

Commit

Permalink
[MIG] hr_timesheet_sheet: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sowrirajan committed Jun 11, 2024
1 parent f0b7199 commit e952741
Show file tree
Hide file tree
Showing 27 changed files with 211 additions and 168 deletions.
84 changes: 46 additions & 38 deletions hr_timesheet_sheet/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ HR Timesheet Sheet
: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/16.0/hr_timesheet_sheet
:target: https://github.com/OCA/timesheet/tree/17.0/hr_timesheet_sheet
:alt: OCA/timesheet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_timesheet_sheet
:target: https://translation.odoo-community.org/projects/timesheet-17-0/timesheet-17-0-hr_timesheet_sheet
: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=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module supplies a new screen enabling you to manage your work encoding
(timesheet) by period. Timesheet entries are made by employees each day. At the
end of the defined period, employees submit their validated sheet and the
reviewer must then approve submitted entries. Periods are defined in the
company forms and you can set them to run monthly, weekly or daily. By default,
policy is configured to have HR Officers as reviewers.
This module supplies a new screen enabling you to manage your work
encoding (timesheet) by period. Timesheet entries are made by employees
each day. At the end of the defined period, employees submit their
validated sheet and the reviewer must then approve submitted entries.
Periods are defined in the company forms and you can set them to run
monthly, weekly or daily. By default, policy is configured to have HR
Officers as reviewers.

**Table of contents**

Expand All @@ -45,76 +46,83 @@ Installation

This module relies on:

* The OCA module '2D matrix for x2many fields', and can be downloaded from
Github: https://github.com/OCA/web/tree/16.0/web_widget_x2many_2d_matrix
- The OCA module '2D matrix for x2many fields', and can be downloaded
from Github:
https://github.com/OCA/web/tree/16.0/web_widget_x2many_2d_matrix

Configuration
=============

If you want other default ranges different from weekly, you need to go:

* In the menu `Configuration` -> `Settings` -> **Timesheet Options**,
and select in **Timesheet Sheet Range** the default range you want.
* When you have a weekly range you can also specify the **Week Start Day**.
- In the menu Configuration -> Settings -> **Timesheet Options**, and
select in **Timesheet Sheet Range** the default range you want.
- When you have a weekly range you can also specify the **Week Start
Day**.

To change who reviews submitted sheets, go to *Configuration > Settings > Timesheet Options*
and configure **Timesheet Sheet Review Policy** accordingly.
To change who reviews submitted sheets, go to *Configuration > Settings
> Timesheet Options* and configure **Timesheet Sheet Review Policy**
accordingly.

For adding more review policies, look at the *hr_timesheet_sheet_policy_xxx*
extra modules.
For adding more review policies, look at the
*hr_timesheet_sheet_policy_xxx* extra modules.

Usage
=====

If you modify the `Details` tab, automatically the `Summary` tab is updated.
But if you modify the `Summary` tab, you need to save in order to have the `Details` tab updated.
If you modify the Details tab, automatically the Summary tab is updated.
But if you modify the Summary tab, you need to save in order to have the
Details tab updated.

In case you modify the unit amount of both tabs, the `Details` tab will prevail.
If you modify the `Summary` tab, and you need to do a change in the `Details` tab, please save before.
In case you modify the unit amount of both tabs, the Details tab will
prevail. If you modify the Summary tab, and you need to do a change in
the Details tab, please save before.

Known issues / Roadmap
======================

* The timesheet grid is limited to display a max. of 1M cells, due to a
limitation of the tree view limit parameter not being able to dynamically
set a limit. Since default value of odoo, 40 records is too small, we decided
to set 1M, which should be good enough in the majority of scenarios.
- The timesheet grid is limited to display a max. of 1M cells, due to a
limitation of the tree view limit parameter not being able to
dynamically set a limit. Since default value of odoo, 40 records is
too small, we decided to set 1M, which should be good enough in the
majority of scenarios.

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_timesheet_sheet%0Aversion:%2016.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_timesheet_sheet%0Aversion:%2017.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.

Credits
=======

Authors
~~~~~~~
-------

* ForgeFlow
* Onestein
* CorporateHub

Contributors
~~~~~~~~~~~~
------------

* Miquel Raïch <[email protected]>
* Andrea Stirpe <[email protected]>
* Lois Rilo <[email protected]>
* `CorporateHub <https://corporatehub.eu/>`__
- Miquel Raïch <[email protected]>
- Andrea Stirpe <[email protected]>
- Lois Rilo <[email protected]>
- `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <[email protected]>
- Alexey Pelykh <[email protected]>

* Dennis Sluijk <[email protected]>
* Sunanda Chhatbar <[email protected]>
- Dennis Sluijk <[email protected]>
- Sunanda Chhatbar <[email protected]>
- SodexisTeam <[email protected]>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -126,6 +134,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/16.0/hr_timesheet_sheet>`_ project on GitHub.
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/17.0/hr_timesheet_sheet>`_ 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_timesheet_sheet/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "HR Timesheet Sheet",
"version": "16.0.1.1.1",
"version": "17.0.1.1.1",
"category": "Human Resources",
"sequence": 80,
"summary": "Timesheet Sheets, Activities",
Expand Down
2 changes: 1 addition & 1 deletion hr_timesheet_sheet/models/account_analytic_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AccountAnalyticAccount(models.Model):
def _check_timesheet_sheet_company_id(self):
for rec in self.sudo():
sheets = rec.line_ids.mapped("sheet_id").filtered(
lambda s: s.company_id and s.company_id != rec.company_id
lambda s, rec=rec: s.company_id and rec.company_id != s.company_id
)
if sheets:
raise ValidationError(
Expand Down
23 changes: 21 additions & 2 deletions hr_timesheet_sheet/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,24 @@ def merge_timesheets(self):
self[1:].unlink()
return self[0]

def _check_can_update_timesheet(self):
return super()._check_can_update_timesheet() or not self.filtered("sheet_id")
def _check_can_write(self, values):
is_installed = self.env["ir.module.module"].search(
[("name", "=", "project_timesheet_holidays"), ("state", "=", "installed")]
)
if is_installed:
if not self.env.su:
if (
hasattr(self, "holiday_id")
and self.holiday_id
and values.get("sheet_id", False)
): # Dont raise error during create
return True
if hasattr(self, "holiday_id") and self.holiday_id and self.sheet_id:
raise UserError(
_(
"""You cannot modify timesheets that are linked to \
time off requests.
Please use the Time Off application to modify your time off requests instead."""
)
)
return super()._check_can_write(values)
3 changes: 2 additions & 1 deletion hr_timesheet_sheet/models/hr_department.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def _check_company_id(self):
_(
"You cannot change the company, "
"as this %(rec_name)s (%(rec_display_name)s) "
"is assigned to %(current_name)s (%(current_display_name)s).",
"is assigned to %(current_name)s \
(%(current_display_name)s).",
rec_name=rec._name,
rec_display_name=rec.display_name,
current_name=field._name,
Expand Down
3 changes: 2 additions & 1 deletion hr_timesheet_sheet/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def _check_company_id(self):
_(
"You cannot change the company, "
"as this %(rec_name)s (%(rec_display_name)s) "
"is assigned to %(current_name)s (%(current_display_name)s).",
"is assigned to %(current_name)s \
(%(current_display_name)s).",
rec_name=rec._name,
rec_display_name=rec.display_name,
current_name=field._name,
Expand Down
27 changes: 9 additions & 18 deletions hr_timesheet_sheet/models/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def _default_department_id(self):
default=lambda self: self._default_employee(),
required=True,
readonly=True,
states={"new": [("readonly", False)]},
)
user_id = fields.Many2one(
comodel_name="res.users",
Expand All @@ -78,36 +77,31 @@ def _default_department_id(self):
required=True,
index=True,
readonly=True,
states={"new": [("readonly", False)]},
)
date_end = fields.Date(
string="Date To",
default=lambda self: self._default_date_end(),
required=True,
index=True,
readonly=True,
states={"new": [("readonly", False)]},
)
timesheet_ids = fields.One2many(
comodel_name="account.analytic.line",
inverse_name="sheet_id",
string="Timesheets",
readonly=True,
states={"new": [("readonly", False)], "draft": [("readonly", False)]},
)
line_ids = fields.One2many(
comodel_name="hr_timesheet.sheet.line",
compute="_compute_line_ids",
string="Timesheet Sheet Lines",
readonly=True,
states={"new": [("readonly", False)], "draft": [("readonly", False)]},
)
new_line_ids = fields.One2many(
comodel_name="hr_timesheet.sheet.new.analytic.line",
inverse_name="sheet_id",
string="Temporary Timesheets",
readonly=True,
states={"new": [("readonly", False)], "draft": [("readonly", False)]},
)
state = fields.Selection(
[
Expand Down Expand Up @@ -141,7 +135,6 @@ def _default_department_id(self):
string="Department",
default=lambda self: self._default_department_id(),
readonly=True,
states={"new": [("readonly", False)]},
)
reviewer_id = fields.Many2one(
comodel_name="hr.employee", string="Reviewer", readonly=True, tracking=True
Expand Down Expand Up @@ -244,7 +237,7 @@ def _check_start_end_dates(self):
def _get_complete_name_components(self):
"""Hook for extensions"""
self.ensure_one()
return [self.employee_id.name_get()[0][1]]
return [self.employee_id.display_name]

def _get_overlapping_sheet_domain(self):
"""Hook for extensions"""
Expand Down Expand Up @@ -404,9 +397,9 @@ def _get_matrix_key_values_for_line(self, aal):
def _get_matrix_sortby(self, key):
res = []
for attribute in key:
if hasattr(attribute, "name_get"):
name = attribute.name_get()
value = name[0][1] if name else ""
if hasattr(attribute, "display_name"):
name = attribute.display_name
value = name if name else ""
else:
value = attribute
res.append(value)
Expand Down Expand Up @@ -612,11 +605,9 @@ def _get_dates(self):
def _get_line_name(self, project_id, task_id=None, **kwargs):
self.ensure_one()
if task_id:
return "{} - {}".format(
project_id.name_get()[0][1], task_id.name_get()[0][1]
)
return f"{project_id.display_name} - {task_id.display_name}"

return project_id.name_get()[0][1]
return project_id.display_name

def _get_new_line_unique_id(self):
"""Hook for extensions"""
Expand Down Expand Up @@ -702,7 +693,7 @@ def _is_line_of_row(self, aal, row):
def delete_empty_lines(self, delete_empty_rows=False):
self.ensure_one()
for name in list(set(self.line_ids.mapped("value_y"))):
rows = self.line_ids.filtered(lambda l: l.value_y == name)
rows = self.line_ids.filtered(lambda x, name=name: x.value_y == name)
if not rows:
continue
row = fields.first(rows)
Expand All @@ -713,7 +704,7 @@ def delete_empty_lines(self, delete_empty_rows=False):
if not check:
continue
row_lines = self.timesheet_ids.filtered(
lambda aal: self._is_line_of_row(aal, row)
lambda aal, row=row: self._is_line_of_row(aal, row)
)
row_lines.filtered(
lambda t: t.name == empty_name
Expand Down Expand Up @@ -767,7 +758,7 @@ def add_new_line(self, line):
self.ensure_one()
new_line_model = self.env["hr_timesheet.sheet.new.analytic.line"]
new_line = self.new_line_ids.filtered(
lambda l: self._is_compatible_new_line(l, line)
lambda x: self._is_compatible_new_line(x, line)
)
if new_line:
new_line.write({"unit_amount": line.unit_amount})
Expand Down
3 changes: 3 additions & 0 deletions hr_timesheet_sheet/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
13 changes: 13 additions & 0 deletions hr_timesheet_sheet/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
If you want other default ranges different from weekly, you need to go:

- In the menu Configuration -\> Settings -\> **Timesheet Options**, and
select in **Timesheet Sheet Range** the default range you want.
- When you have a weekly range you can also specify the **Week Start
Day**.

To change who reviews submitted sheets, go to *Configuration \> Settings
\> Timesheet Options* and configure **Timesheet Sheet Review Policy**
accordingly.

For adding more review policies, look at the
*hr_timesheet_sheet_policy_xxx* extra modules.
11 changes: 0 additions & 11 deletions hr_timesheet_sheet/readme/CONFIGURE.rst

This file was deleted.

8 changes: 8 additions & 0 deletions hr_timesheet_sheet/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Miquel Raïch \<<[email protected]>\>
- Andrea Stirpe \<<[email protected]>\>
- Lois Rilo \<<[email protected]>\>
- [CorporateHub](https://corporatehub.eu/)
- Alexey Pelykh \<<[email protected]>\>
- Dennis Sluijk \<<[email protected]>\>
- Sunanda Chhatbar \<<[email protected]>\>
- SodexisTeam \<<[email protected]>\>
9 changes: 0 additions & 9 deletions hr_timesheet_sheet/readme/CONTRIBUTORS.rst

This file was deleted.

7 changes: 7 additions & 0 deletions hr_timesheet_sheet/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module supplies a new screen enabling you to manage your work
encoding (timesheet) by period. Timesheet entries are made by employees
each day. At the end of the defined period, employees submit their
validated sheet and the reviewer must then approve submitted entries.
Periods are defined in the company forms and you can set them to run
monthly, weekly or daily. By default, policy is configured to have HR
Officers as reviewers.
6 changes: 0 additions & 6 deletions hr_timesheet_sheet/readme/DESCRIPTION.rst

This file was deleted.

Loading

0 comments on commit e952741

Please sign in to comment.