Skip to content

Commit

Permalink
[MIG] hr_timesheet_sheet: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Nov 26, 2024
1 parent fe5dbed commit fbae67b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 65 deletions.
10 changes: 5 additions & 5 deletions hr_timesheet_sheet/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ 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/17.0/hr_timesheet_sheet
:target: https://github.com/OCA/timesheet/tree/18.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-17-0/timesheet-17-0-hr_timesheet_sheet
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-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=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -93,7 +93,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_timesheet_sheet%0Aversion:%2017.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:%2018.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 @@ -137,6 +137,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/17.0/hr_timesheet_sheet>`_ project on GitHub.
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.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": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Human Resources",
"sequence": 80,
"summary": "Timesheet Sheets, Activities",
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/models/account_analytic_account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo import api, models
from odoo.exceptions import ValidationError


Expand All @@ -16,7 +16,7 @@ def _check_timesheet_sheet_company_id(self):
)
if sheets:
raise ValidationError(
_(
rec.env._(
"You cannot change the company, as this "
"%(rec_name)s (%(rec_display_name)s) is assigned "
"to %(current_name)s (%(current_display_name)s).",
Expand Down
8 changes: 4 additions & 4 deletions hr_timesheet_sheet/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2018-2019 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError


Expand Down Expand Up @@ -44,7 +44,7 @@ def _check_company_id_sheet_id(self):
and aal.company_id != aal.sheet_id.company_id
):
raise ValidationError(
_(
aal.env._(
"You cannot create a timesheet of a different company "
"than the one of the timesheet sheet:"
"\n - %(sheet_name)s of %(sheet_company)s"
Expand Down Expand Up @@ -121,7 +121,7 @@ def _check_state(self):
for line in self.exists().filtered("sheet_id"):
if line.sheet_id.state not in ["new", "draft"]:
raise UserError(
_(
line.env._(
"You cannot modify an entry in a confirmed timesheet sheet"
": %(names)s",
names=line.sheet_id.complete_name,
Expand Down Expand Up @@ -156,7 +156,7 @@ def _check_can_write(self, values):
return True
if hasattr(self, "holiday_id") and self.holiday_id and self.sheet_id:
raise UserError(
_(
self.env._(
"""You cannot modify timesheets that are linked to \
time off requests.
Please use the Time Off application to modify your time off requests instead."""
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/models/hr_department.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2018 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -44,7 +44,7 @@ def _check_company_id(self):
and rec.company_id != field.company_id
):
raise ValidationError(
_(
rec.env._(
"You cannot change the company, as this"
" %(rec_name)s (%(rec_display_name)s) is assigned"
" to %(current_name)s (%(current_display_name)s).",
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -44,7 +44,7 @@ def _check_company_id(self):
and rec.company_id != field.company_id
):
raise ValidationError(
_(
rec.env._(
"You cannot change the company, as this"
" %(rec_name)s (%(rec_display_name)s) is assigned"
" to %(current_name)s (%(current_display_name)s).",
Expand Down
42 changes: 22 additions & 20 deletions hr_timesheet_sheet/models/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import babel.dates
from dateutil.relativedelta import SU, relativedelta

from odoo import SUPERUSER_ID, _, api, fields, models
from odoo import SUPERUSER_ID, api, fields, models
from odoo.exceptions import UserError, ValidationError

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -158,7 +158,7 @@ def _compute_name(self):
locale = self.env.context.get("lang") or self.env.user.lang or "en_US"
for sheet in self:
if not sheet.date_start or not sheet.date_end:
raise UserError(_("Please enter start and end date"))
raise UserError(sheet.env._("Please enter start and end date"))
if sheet.date_start == sheet.date_end:
sheet.name = babel.dates.format_skeleton(
skeleton="MMMEd",
Expand All @@ -171,9 +171,9 @@ def _compute_name(self):
period_end = sheet.date_end.strftime("%V, %Y")

if sheet.date_end <= sheet.date_start + relativedelta(weekday=SU):
sheet.name = _("Week %(end)s", end=period_end)
sheet.name = sheet.env._("Week %(end)s", end=period_end)
else:
sheet.name = _(
sheet.name = sheet.env._(
"Weeks %(start)s - %(end)s", start=period_start, end=period_end
)

Expand Down Expand Up @@ -222,7 +222,7 @@ def _check_start_end_dates(self):
for sheet in self:
if sheet.date_start > sheet.date_end:
raise ValidationError(
_("The start date cannot be later than the end date.")
sheet.env._("The start date cannot be later than the end date.")
)

def _get_complete_name_components(self):
Expand All @@ -249,7 +249,7 @@ def _check_overlapping_sheets(self):
overlapping_sheets = self.search(sheet._get_overlapping_sheet_domain())
if overlapping_sheets:
raise ValidationError(
_(
sheet.env._(
"You cannot have 2 or more sheets that overlap!\n"
'Please use the menu "Timesheet Sheet" '
"to avoid this problem.\nConflicting sheets:\n - %(names)s",
Expand All @@ -268,7 +268,7 @@ def _check_company_id_employee_id(self):
and rec.company_id != rec.employee_id.company_id
):
raise ValidationError(
_(
rec.env._(
"The Company in the Timesheet Sheet and in "
"the Employee must be the same."
)
Expand All @@ -283,7 +283,7 @@ def _check_company_id_department_id(self):
and rec.company_id != rec.department_id.company_id
):
raise ValidationError(
_(
rec.env._(
"The Company in the Timesheet Sheet and in "
"the Department must be the same."
)
Expand All @@ -298,7 +298,7 @@ def _check_company_id_add_line_project_id(self):
and rec.company_id != rec.add_line_project_id.company_id
):
raise ValidationError(
_(
rec.env._(
"The Company in the Timesheet Sheet and in "
"the Project must be the same."
)
Expand All @@ -313,7 +313,7 @@ def _check_company_id_add_line_task_id(self):
and rec.company_id != rec.add_line_task_id.company_id
):
raise ValidationError(
_(
rec.env._(
"The Company in the Timesheet Sheet and in "
"the Task must be the same."
)
Expand Down Expand Up @@ -460,7 +460,7 @@ def _check_employee_user_link(self, vals):
employee = self.env["hr.employee"].sudo().browse(vals["employee_id"])
if not employee.user_id:
raise UserError(
_(
employee.env._(
"In order to create a sheet for this employee, you must"
" link him/her to an user: %s"
)
Expand All @@ -471,7 +471,7 @@ def _check_employee_user_link(self, vals):

def copy(self, default=None):
if not self.env.context.get("allow_copy_timesheet"):
raise UserError(_("You cannot duplicate a sheet."))
raise UserError(self.env._("You cannot duplicate a sheet."))
return super().copy(default=default)

@api.model_create_multi
Expand Down Expand Up @@ -499,7 +499,7 @@ def unlink(self):
for sheet in self:
if sheet.state in ("confirm", "done"):
raise UserError(
_(
sheet.env._(
"You cannot delete a timesheet sheet which is already"
" submitted or confirmed: %s",
sheet.complete_name,
Expand Down Expand Up @@ -536,7 +536,7 @@ def _timesheet_subscribe_users(self):

def action_timesheet_draft(self):
if self.filtered(lambda sheet: sheet.state != "done"):
raise UserError(_("Cannot revert to draft a non-approved sheet."))
raise UserError(self.env._("Cannot revert to draft a non-approved sheet."))
self._check_can_review()
self.write({"state": "draft", "reviewer_id": False})

Expand All @@ -547,13 +547,13 @@ def action_timesheet_confirm(self):

def action_timesheet_done(self):
if self.filtered(lambda sheet: sheet.state != "confirm"):
raise UserError(_("Cannot approve a non-submitted sheet."))
raise UserError(self.env._("Cannot approve a non-submitted sheet."))
self._check_can_review()
self.write({"state": "done", "reviewer_id": self._get_current_reviewer().id})

def action_timesheet_refuse(self):
if self.filtered(lambda sheet: sheet.state != "confirm"):
raise UserError(_("Cannot reject a non-submitted sheet."))
raise UserError(self.env._("Cannot reject a non-submitted sheet."))
self._check_can_review()
self.write({"state": "draft", "reviewer_id": False})

Expand All @@ -564,7 +564,7 @@ def _get_current_reviewer(self):
)
if not reviewer:
raise UserError(
_(
reviewer.env._(
"In order to review a timesheet sheet, your user needs to be"
" linked to an employee."
)
Expand All @@ -573,7 +573,9 @@ def _get_current_reviewer(self):

def _check_can_review(self):
if self.filtered(lambda x: not x.can_review and x.review_policy == "hr"):
raise UserError(_("Only a HR Officer or Manager can review the sheet."))
raise UserError(
self.env._("Only a HR Officer or Manager can review the sheet.")
)

def button_add_line(self):
for rec in self:
Expand Down Expand Up @@ -847,8 +849,8 @@ def onchange_unit_amount(self):
if not sheet:
return {
"warning": {
"title": _("Warning"),
"message": _("Save the Timesheet Sheet first."),
"title": self.env._("Warning"),
"message": self.env._("Save the Timesheet Sheet first."),
}
}
sheet.add_new_line(self)
Expand Down
6 changes: 3 additions & 3 deletions hr_timesheet_sheet/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">HR Timesheet Sheet</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fe97bb62b31b55f4ba1245097af703d3e6dc16416ef31f15dc7364171677c9b1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/17.0/hr_timesheet_sheet"><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-17-0/timesheet-17-0-hr_timesheet_sheet"><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=17.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/18.0/hr_timesheet_sheet"><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-18-0/timesheet-18-0-hr_timesheet_sheet"><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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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
Expand Down Expand Up @@ -441,7 +441,7 @@ <h1><a class="toc-backref" href="#toc-entry-5">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_timesheet_sheet%0Aversion:%2017.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_timesheet_sheet%0Aversion:%2018.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 @@ -482,7 +482,7 @@ <h2><a class="toc-backref" href="#toc-entry-9">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/17.0/hr_timesheet_sheet">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/18.0/hr_timesheet_sheet">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
5 changes: 3 additions & 2 deletions hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from odoo import fields
from odoo.exceptions import UserError, ValidationError
from odoo.tests.common import Form, TransactionCase
from odoo.tests import Form
from odoo.tests.common import TransactionCase

from ..models.hr_timesheet_sheet import empty_name

Expand Down Expand Up @@ -1026,7 +1027,7 @@ def test_workflow(self):
sheet = Form(self.sheet_model.with_user(self.user)).save()

self.sheet_model.with_user(self.user).get_view(view_type="form")
self.sheet_model.with_user(self.user).get_view(view_type="tree")
self.sheet_model.with_user(self.user).get_view(view_type="list")

with self.assertRaises(UserError):
sheet.with_user(self.user_3).action_timesheet_refuse()
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/views/hr_department_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<record id="hr_timesheet_action_from_department" model="ir.actions.act_window">
<field name="name">Timesheets to Review</field>
<field name="res_model">hr_timesheet.sheet</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="context">{
'search_default_department_id': [active_id],
'default_department_id': active_id,
Expand All @@ -25,7 +25,7 @@
groups="hr_timesheet.group_hr_timesheet_user"
/>
</xpath>
<xpath expr="//div[hasclass('o_kanban_primary_right')]" position="inside">
<xpath expr="//div[@name='kanban_primary_right']" position="inside">
<div
t-if="record.timesheet_sheet_to_approve_count.raw_value > 0"
class="row ml16"
Expand Down
Loading

0 comments on commit fbae67b

Please sign in to comment.