Skip to content

Commit

Permalink
[MIG] hr_timesheet_task_required: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 15, 2025
1 parent 6826f0c commit 14664ac
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
27 changes: 14 additions & 13 deletions hr_timesheet_task_required/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Hr Timesheet Task Required
: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_task_required
:target: https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_task_required
: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_task_required
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-hr_timesheet_task_required
: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 @@ -56,7 +56,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_task_required%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_task_required%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 All @@ -72,16 +72,17 @@ Authors
Contributors
------------

- Adrien Peiffer <[email protected]>
- Laurent Mignon <[email protected]>
- Benjamin Willig <[email protected]>
- `CorporateHub <https://corporatehub.eu/>`__
- Adrien Peiffer <[email protected]>
- Laurent Mignon <[email protected]>
- Benjamin Willig <[email protected]>
- `CorporateHub <https://corporatehub.eu/>`__

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

- Saran Lim. <[email protected]>
- Foram Shah <[email protected]>
- Houssine Bakkali <[email protected]>
- Saran Lim. <[email protected]>
- Foram Shah <[email protected]>
- Houssine Bakkali <[email protected]>
- ``Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>``\ \_

Maintainers
-----------
Expand All @@ -96,6 +97,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_task_required>`_ project on GitHub.
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_task_required>`_ 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_task_required/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Hr Timesheet Task Required",
"summary": """
Set task on timesheet as a mandatory field""",
"version": "17.0.1.0.1",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, CorporateHub, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/timesheet",
Expand Down
10 changes: 5 additions & 5 deletions hr_timesheet_task_required/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# 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 ValidationError


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

is_task_required = fields.Boolean(
string="Is Task Required", related="project_id.is_timesheet_task_required"
)
is_task_required = fields.Boolean(related="project_id.is_timesheet_task_required")

@api.constrains("project_id", "task_id")
def _check_timesheet_task(self):
for line in self:
if line.is_task_required and not line.task_id:
raise ValidationError(_("You must specify a task for timesheet lines."))
raise ValidationError(
self.env._("You must specify a task for timesheet lines.")
)
1 change: 1 addition & 0 deletions hr_timesheet_task_required/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Saran Lim. \<<[email protected]>\>
- Foram Shah \<<[email protected]>\>
- Houssine Bakkali \<<[email protected]>\>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
18 changes: 11 additions & 7 deletions hr_timesheet_task_required/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Hr Timesheet Task Required</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f8501c73ef6470fdc79a7a9a6b2e05c513be62054670b2e2840f061a009c2fdb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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_task_required"><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_task_required"><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_task_required"><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_task_required"><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 allows to configure project as having task on timesheet as a
mandatory field.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -399,7 +400,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">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_task_required%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_task_required%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 All @@ -424,16 +425,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</li>
<li>Houssine Bakkali &lt;<a class="reference external" href="mailto:houssine.bakkali&#64;eezee-it.com">houssine.bakkali&#64;eezee-it.com</a>&gt;</li>
<li><tt class="docutils literal">Heliconia Solutions Pvt. Ltd. <span class="pre">&lt;https://www.heliconia.io&gt;</span></tt>_</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<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_task_required">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_task_required">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
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ def test_timesheet_line_task_required(self):
)

def test_timesheet_line_task_not_required(self):
self.AnalyticLine.create(
# Project with task not required
self.assertFalse(self.project_2.is_timesheet_task_required)

# Create a timesheet line without a task
timesheet_line = self.AnalyticLine.create(
{
"name": "test",
"project_id": self.project_2.id,
"unit_amount": 10,
"employee_id": self.employee.id,
}
)
self.assertTrue(timesheet_line)

self.AnalyticLine.create(
# Create a timesheet line with a task
timesheet_line_with_task = self.AnalyticLine.create(
{
"name": "test",
"project_id": self.project_2.id,
Expand All @@ -68,3 +74,4 @@ def test_timesheet_line_task_not_required(self):
"employee_id": self.employee.id,
}
)
self.assertTrue(timesheet_line_with_task)
6 changes: 0 additions & 6 deletions hr_timesheet_task_required/views/account_analytic_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form" />
<field name="arch" type="xml">
<field name="task_id" position="before">
<field name="is_task_required" invisible="1" />
</field>
<field name="task_id" position="attributes">
<attribute name="required">is_task_required</attribute>
</field>
Expand All @@ -23,9 +20,6 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
<field name="arch" type="xml">
<field name="task_id" position="before">
<field name="is_task_required" column_invisible="1" />
</field>
<field name="task_id" position="attributes">
<attribute name="required">is_task_required</attribute>
</field>
Expand Down
7 changes: 4 additions & 3 deletions hr_timesheet_task_required/views/project_project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
<field name="allow_timesheets" position="after">
<field
name="is_timesheet_task_required"
invisible="allow_timesheets == False"
invisible="not allow_timesheets"
/>
</field>
</field>
Expand All @@ -25,11 +25,12 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
<field name="model">project.project</field>
<field name="inherit_id" ref="hr_timesheet.project_invoice_form" />
<field name="arch" type="xml">
<xpath expr="//setting[@id='timesheet_settings']" position="after">
<xpath expr="//group[@name='group_time_managment']" position="after">
<setting />
<setting
id="timesheet_task_settings"
help="Set tasks on timesheet as a mandatory field"
invisible="allow_timesheets == False"
invisible="not allow_timesheets"
>
<field name="is_timesheet_task_required" />
</setting>
Expand Down

0 comments on commit 14664ac

Please sign in to comment.