Skip to content

Commit e181e27

Browse files
[MIG] hr_timesheet_task_domain: Migration to 18.0
1 parent 6ac0794 commit e181e27

File tree

6 files changed

+179
-21
lines changed

6 files changed

+179
-21
lines changed

hr_timesheet_task_domain/README.rst

+21-17
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Task Log: limit Task by Project
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github
20-
:target: https://github.com/OCA/timesheet/tree/17.0/hr_timesheet_task_domain
20+
:target: https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_task_domain
2121
:alt: OCA/timesheet
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/timesheet-17-0/timesheet-17-0-hr_timesheet_task_domain
23+
:target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-hr_timesheet_task_domain
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=18.0
2727
:alt: Try me on Runboat
2828

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

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

@@ -59,22 +59,26 @@ Authors
5959
Contributors
6060
------------
6161

62-
- `Tecnativa <https://www.tecnativa.com>`__:
62+
- `Tecnativa <https://www.tecnativa.com>`__:
6363

64-
- Pedro M. Baeza
65-
- Antonio Espinosa
66-
- Carlos Dauden
67-
- Sergio Teruel
68-
- Luis M. ontalba
69-
- Ernesto Tejeda
70-
- Manuel Calero
71-
- Yadier Quesada
64+
- Pedro M. Baeza
65+
- Antonio Espinosa
66+
- Carlos Dauden
67+
- Sergio Teruel
68+
- Luis M. ontalba
69+
- Ernesto Tejeda
70+
- Manuel Calero
71+
- Yadier Quesada
7272

73-
- `CorporateHub <https://corporatehub.eu/>`__
73+
- `CorporateHub <https://corporatehub.eu/>`__
7474

75-
- Alexey Pelykh <alexey.pelykh@corphub.eu>
75+
- Alexey Pelykh <alexey.pelykh@corphub.eu>
7676

77-
- Foram Shah <foram.shah@initos.com>
77+
- Foram Shah <foram.shah@initos.com>
78+
79+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
80+
81+
- Bhavesh Heliconia
7882

7983
Maintainers
8084
-----------
@@ -89,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
8993
mission is to support the collaborative development of Odoo features and
9094
promote its widespread use.
9195

92-
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/17.0/hr_timesheet_task_domain>`_ project on GitHub.
96+
This module is part of the `OCA/timesheet <https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_task_domain>`_ project on GitHub.
9397

9498
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

hr_timesheet_task_domain/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
{
1111
"name": "Task Log: limit Task by Project",
12-
"version": "17.0.1.0.0",
12+
"version": "18.0.1.0.0",
1313
"category": "Human Resources",
1414
"website": "https://github.com/OCA/timesheet",
1515
"author": "Tecnativa, CorporateHub, Odoo Community Association (OCA)",

hr_timesheet_task_domain/readme/CONTRIBUTORS.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@
1414
- Alexey Pelykh \<<alexey.pelykh@corphub.eu>\>
1515

1616
- Foram Shah \<<foram.shah@initos.com>\>
17+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
18+
- Bhavesh Heliconia
19+

hr_timesheet_task_domain/static/description/index.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Task Log: limit Task by Project</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:b2119664ace110682f4434eb89adb0f8177347388a0c135f6232ad2d2b3d63b5
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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_domain"><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_domain"><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>
372+
<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_domain"><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_domain"><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>
373373
<p>This module adjusts the domain applied to task field in order to limit
374374
task selection to currently-selected project, also limits selection to
375375
tasks in any of “Open” stages in order to accommodate a project flow.</p>
@@ -390,7 +390,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
390390
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/timesheet/issues">GitHub Issues</a>.
391391
In case of trouble, please check there if your issue has already been reported.
392392
If you spotted it first, help us to smash it by providing a detailed and welcomed
393-
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_task_domain%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
393+
<a class="reference external" href="https://github.com/OCA/timesheet/issues/new?body=module:%20hr_timesheet_task_domain%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
394394
<p>Do not contact contributors directly about support or help with technical issues.</p>
395395
</div>
396396
<div class="section" id="credits">
@@ -426,6 +426,11 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
426426
</li>
427427
<li><p class="first">Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</p>
428428
</li>
429+
<li><p class="first"><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></p>
430+
<ul class="simple">
431+
<li>Bhavesh Heliconia</li>
432+
</ul>
433+
</li>
429434
</ul>
430435
</div>
431436
<div class="section" id="maintainers">
@@ -437,7 +442,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
437442
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
438443
mission is to support the collaborative development of Odoo features and
439444
promote its widespread use.</p>
440-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/17.0/hr_timesheet_task_domain">OCA/timesheet</a> project on GitHub.</p>
445+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/timesheet/tree/18.0/hr_timesheet_task_domain">OCA/timesheet</a> project on GitHub.</p>
441446
<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>
442447
</div>
443448
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import account_analytic_line_test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
from odoo.tests import Form
2+
from odoo.tests.common import TransactionCase
3+
4+
5+
class TestAccountAnalyticLine(TransactionCase):
6+
@classmethod
7+
def setUpClass(cls):
8+
super().setUpClass()
9+
10+
# Create companies
11+
cls.company_1 = cls.env["res.company"].create(
12+
{
13+
"name": "Test Company 1",
14+
}
15+
)
16+
cls.company_2 = cls.env["res.company"].create(
17+
{
18+
"name": "Test Company 2",
19+
}
20+
)
21+
22+
# Create projects
23+
cls.project_1 = cls.env["project.project"].create(
24+
{
25+
"name": "Test Project 1",
26+
"company_id": cls.company_1.id,
27+
"allow_timesheets": True,
28+
}
29+
)
30+
cls.project_2 = cls.env["project.project"].create(
31+
{
32+
"name": "Test Project 2",
33+
"company_id": cls.company_2.id,
34+
"allow_timesheets": True,
35+
}
36+
)
37+
cls.project_no_timesheet = cls.env["project.project"].create(
38+
{
39+
"name": "Project No Timesheet",
40+
"company_id": cls.company_1.id,
41+
"allow_timesheets": False,
42+
}
43+
)
44+
45+
# Create tasks
46+
cls.task_1 = cls.env["project.task"].create(
47+
{
48+
"name": "Test Task 1",
49+
"project_id": cls.project_1.id,
50+
"company_id": cls.company_1.id,
51+
}
52+
)
53+
cls.task_2 = cls.env["project.task"].create(
54+
{
55+
"name": "Test Task 2",
56+
"project_id": cls.project_2.id,
57+
"company_id": cls.company_2.id,
58+
}
59+
)
60+
cls.task_closed = cls.env["project.task"].create(
61+
{
62+
"name": "Closed Task",
63+
"project_id": cls.project_1.id,
64+
"company_id": cls.company_1.id,
65+
"state": "done",
66+
}
67+
)
68+
cls.task_no_timesheet = cls.env["project.task"].create(
69+
{
70+
"name": "Task No Timesheet",
71+
"project_id": cls.project_no_timesheet.id,
72+
"company_id": cls.company_1.id,
73+
}
74+
)
75+
76+
def test_task_id_domain_with_project(self):
77+
"""Test task_id domain when project_id is set"""
78+
analytic_line = self.env["account.analytic.line"].create(
79+
{
80+
"name": "Test Line",
81+
"project_id": self.project_1.id,
82+
"company_id": self.company_1.id,
83+
}
84+
)
85+
86+
# Use Form to test domain
87+
with Form(analytic_line) as line_form:
88+
# Should allow tasks from same project and company
89+
line_form.task_id = self.task_1
90+
91+
# Should not allow tasks from different project
92+
with self.assertRaises(AssertionError):
93+
line_form.task_id = self.task_2
94+
95+
# Should not allow closed tasks
96+
with self.assertRaises(AssertionError):
97+
line_form.task_id = self.task_closed
98+
99+
# Should not allow tasks from projects without timesheets
100+
with self.assertRaises(AssertionError):
101+
line_form.task_id = self.task_no_timesheet
102+
103+
def test_task_id_domain_without_project(self):
104+
"""Test task_id domain when project_id is not set"""
105+
analytic_line = self.env["account.analytic.line"].create(
106+
{
107+
"name": "Test Line",
108+
"company_id": self.company_1.id,
109+
}
110+
)
111+
112+
# Use Form to test domain
113+
with Form(analytic_line) as line_form:
114+
# Should allow tasks from projects with timesheets
115+
line_form.task_id = self.task_1
116+
117+
# Should not allow tasks from different company
118+
with self.assertRaises(AssertionError):
119+
line_form.task_id = self.task_2
120+
121+
# Should not allow tasks from projects without timesheets
122+
with self.assertRaises(AssertionError):
123+
line_form.task_id = self.task_no_timesheet
124+
125+
# Should not allow closed tasks
126+
with self.assertRaises(AssertionError):
127+
line_form.task_id = self.task_closed
128+
129+
def test_task_id_company_consistency(self):
130+
"""Test company consistency between task and analytic line"""
131+
# Create analytic line with company_1
132+
analytic_line = self.env["account.analytic.line"].create(
133+
{
134+
"name": "Test Line",
135+
"company_id": self.company_1.id,
136+
}
137+
)
138+
139+
# Should be able to set task from same company
140+
analytic_line.task_id = self.task_1
141+
self.assertEqual(analytic_line.task_id, self.task_1)
142+
143+
# Should not be able to set task from different company
144+
with self.assertRaises(AssertionError):
145+
analytic_line.task_id = self.task_2

0 commit comments

Comments
 (0)