Skip to content

Commit 3b27f5d

Browse files
committed
[MIG] maintenance_timesheet_time_control: Migration to 18.0
1 parent d7b60fd commit 3b27f5d

5 files changed

Lines changed: 40 additions & 97 deletions

File tree

maintenance_timesheet_time_control/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Maintenance Timesheets Time Control
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%2Fmaintenance-lightgray.png?logo=github
20-
:target: https://github.com/OCA/maintenance/tree/17.0/maintenance_timesheet_time_control
20+
:target: https://github.com/OCA/maintenance/tree/18.0/maintenance_timesheet_time_control
2121
:alt: OCA/maintenance
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/maintenance-17-0/maintenance-17-0-maintenance_timesheet_time_control
23+
:target: https://translation.odoo-community.org/projects/maintenance-18-0/maintenance-18-0-maintenance_timesheet_time_control
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/maintenance&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/maintenance&target_branch=18.0
2727
:alt: Try me on Runboat
2828

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

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

@@ -124,6 +124,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
124124

125125
|maintainer-victoralmau|
126126

127-
This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/17.0/maintenance_timesheet_time_control>`_ project on GitHub.
127+
This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/18.0/maintenance_timesheet_time_control>`_ project on GitHub.
128128

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

maintenance_timesheet_time_control/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Maintenance Timesheets Time Control",
66
"summary": "Maintenance Timesheets Timesheet Time Control",
7-
"version": "17.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"license": "AGPL-3",
99
"category": "Hidden",
1010
"author": "Tecnativa,Odoo Community Association (OCA)",

maintenance_timesheet_time_control/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Maintenance Timesheets Time Control</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:ba2016f2ac2541372496f5f92627d2adf485d1579f8a215722b02650a4729d55
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/maintenance/tree/17.0/maintenance_timesheet_time_control"><img alt="OCA/maintenance" src="https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/maintenance-17-0/maintenance-17-0-maintenance_timesheet_time_control"><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/maintenance&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/maintenance/tree/18.0/maintenance_timesheet_time_control"><img alt="OCA/maintenance" src="https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/maintenance-18-0/maintenance-18-0-maintenance_timesheet_time_control"><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/maintenance&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>It allows to track the exact moment when a timesheet line is started
374374
(not only the day, but also the minute and second) and let users start
375375
and stop timers easily.</p>
@@ -429,7 +429,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
429429
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/maintenance/issues">GitHub Issues</a>.
430430
In case of trouble, please check there if your issue has already been reported.
431431
If you spotted it first, help us to smash it by providing a detailed and welcomed
432-
<a class="reference external" href="https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_timesheet_time_control%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
432+
<a class="reference external" href="https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_timesheet_time_control%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
433433
<p>Do not contact contributors directly about support or help with technical issues.</p>
434434
</div>
435435
<div class="section" id="credits">
@@ -461,7 +461,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
461461
promote its widespread use.</p>
462462
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
463463
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
464-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/maintenance/tree/17.0/maintenance_timesheet_time_control">OCA/maintenance</a> project on GitHub.</p>
464+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/maintenance/tree/18.0/maintenance_timesheet_time_control">OCA/maintenance</a> project on GitHub.</p>
465465
<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>
466466
</div>
467467
</div>
Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
# Copyright 2022-2024 Tecnativa - Víctor Martínez
22
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
33

4-
from datetime import datetime, timedelta
4+
from odoo import exceptions, fields
5+
from odoo.tests.common import users
56

6-
from odoo import exceptions
7-
from odoo.tests import new_test_user, users
7+
from odoo.addons.project_timesheet_time_control.tests import (
8+
test_project_timesheet_time_control,
9+
)
810

9-
from odoo.addons.base.tests.common import BaseCommon
1011

11-
12-
class TestMaintenanceTimesheetTimeControl(BaseCommon):
12+
class TestMaintenanceTimesheetTimeControl(
13+
test_project_timesheet_time_control.TestProjectTimesheetTimeControlBase
14+
):
1315
@classmethod
1416
def setUpClass(cls):
1517
super().setUpClass()
16-
cls.user = new_test_user(
17-
cls.env,
18-
login="test-maintenance-user",
19-
groups="maintenance.group_equipment_manager,"
20-
"hr_timesheet.group_hr_timesheet_user",
21-
)
22-
cls.user.action_create_employee()
23-
cls.project = cls.env["project.project"].create(
24-
{"name": "Test project", "allow_timesheets": True}
25-
)
18+
cls.user.groups_id |= cls.env.ref("maintenance.group_equipment_manager")
2619
cls.category = cls.env["maintenance.equipment.category"].create(
2720
{"name": "Test category"}
2821
)
@@ -35,62 +28,32 @@ def setUpClass(cls):
3528
"maintenance_team_id": cls.team.id,
3629
}
3730
)
38-
39-
def _create_analytic_line(self, request):
40-
return self.env["account.analytic.line"].create(
41-
{
42-
"date_time": datetime.now() - timedelta(hours=1),
43-
"maintenance_request_id": request.id,
44-
"project_id": request.project_id.id,
45-
"account_id": request.project_id.analytic_account_id.id,
46-
"name": "Test Maintenance Request Timesheet line",
47-
"user_id": self.env.user.id,
48-
}
49-
)
50-
51-
def _create_wizard(self, action, active_record):
52-
self.assertEqual(action["res_model"], "hr.timesheet.switch")
53-
self.assertEqual(action["target"], "new")
54-
self.assertEqual(action["type"], "ir.actions.act_window")
55-
self.assertEqual(action["view_mode"], "form")
56-
return (
57-
active_record.env[action["res_model"]]
58-
.with_context(
59-
active_id=active_record.id,
60-
active_ids=active_record.ids,
61-
active_model=active_record._name,
62-
**action.get("context", {}),
63-
)
64-
.create({})
31+
cls.request = cls.env["maintenance.request"].create(
32+
{"name": "Test computer request", "equipment_id": cls.equipment.id}
6533
)
34+
cls.line.maintenance_request_id = cls.request
6635

67-
@users("test-maintenance-user")
36+
@users("test-user")
6837
def test_maintenance_request_time_control_flow(self):
69-
request = self.env["maintenance.request"].create(
70-
{"name": "Test computer request", "equipment_id": self.equipment.id}
71-
)
72-
analytic_line = self._create_analytic_line(request)
7338
# Running line found, stop the timer
74-
self.assertEqual(request.show_time_control, "stop")
75-
request.button_end_work()
76-
# No more running lines, cannot stop again
39+
self.line.button_end_work()
7740
with self.assertRaises(exceptions.UserError):
78-
request.button_end_work()
41+
self.request.button_end_work()
7942
# All lines stopped, start new one
80-
self.assertEqual(request.show_time_control, "start")
81-
start_action = request.button_start_work()
82-
wizard = self._create_wizard(start_action, request)
83-
self.assertLessEqual(wizard.date_time, datetime.now())
84-
self.assertEqual(wizard.name, analytic_line.name)
85-
self.assertEqual(wizard.project_id, request.project_id)
43+
self.assertEqual(self.request.show_time_control, "start")
44+
start_action = self.request.button_start_work()
45+
wizard = self._create_wizard(start_action, self.line)
46+
self.assertLessEqual(wizard.date_time, fields.Datetime.now())
47+
self.assertEqual(wizard.name, self.line.name)
48+
self.assertEqual(wizard.project_id, self.request.project_id)
8649
self.assertEqual(
87-
wizard.analytic_line_id.account_id, request.project_id.analytic_account_id
50+
wizard.analytic_line_id.account_id, self.request.project_id.account_id
8851
)
89-
self.assertEqual(wizard.analytic_line_id, analytic_line)
52+
self.assertEqual(wizard.analytic_line_id, self.line)
9053
new_act = wizard.with_context(show_created_timer=True).action_switch()
9154
new_line = self.env[new_act["res_model"]].browse(new_act["res_id"])
9255
self.assertEqual(new_line.employee_id, self.env.user.employee_id)
9356
self.assertEqual(new_line.project_id, self.project)
94-
self.assertEqual(new_line.maintenance_request_id, request)
57+
self.assertEqual(new_line.maintenance_request_id, self.request)
9558
self.assertEqual(new_line.unit_amount, 0)
96-
self.assertTrue(analytic_line.unit_amount)
59+
self.assertTrue(self.line.unit_amount)

maintenance_timesheet_time_control/views/maintenance_request_view.xml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
<field name="model">maintenance.request</field>
88
<field
99
name="inherit_id"
10-
ref="maintenance_timesheet.hr_equipment_request_view_form"
10+
ref="maintenance_timesheet.equipment_request_view_form"
1111
/>
1212
<field name="arch" type="xml">
1313
<div name="button_box" position="inside">
14-
<field
15-
name="show_time_control"
16-
groups="hr_timesheet.group_hr_timesheet_user"
17-
invisible="1"
18-
/>
1914
<button
2015
name="button_start_work"
2116
string="Start work"
@@ -49,23 +44,18 @@
4944
<field name="arch" type="xml">
5045
<!-- Sub-tree view for timesheet_ids -->
5146
<xpath
52-
expr="//field[@name='timesheet_ids']/tree//field[@name='date']"
47+
expr="//field[@name='timesheet_ids']/list//field[@name='date']"
5348
position="attributes"
5449
>
5550
<attribute name="invisible">1</attribute>
5651
</xpath>
5752
<xpath
58-
expr="//field[@name='timesheet_ids']/tree//field[@name='date']"
53+
expr="//field[@name='timesheet_ids']/list//field[@name='date']"
5954
position="after"
6055
>
6156
<field name="date_time" string="Date" required="1" />
6257
</xpath>
63-
<xpath expr="//field[@name='timesheet_ids']/tree" position="inside">
64-
<field
65-
name="show_time_control"
66-
groups="hr_timesheet.group_hr_timesheet_user"
67-
invisible="1"
68-
/>
58+
<xpath expr="//field[@name='timesheet_ids']/list" position="inside">
6959
<button
7060
name="button_resume_work"
7161
title="Resume work"
@@ -87,7 +77,7 @@
8777
groups="hr_timesheet.group_hr_timesheet_user"
8878
/>
8979
</xpath>
90-
<xpath expr="//field[@name='timesheet_ids']/tree" position="attributes">
80+
<xpath expr="//field[@name='timesheet_ids']/list" position="attributes">
9181
<attribute name="default_order">date_time</attribute>
9282
</xpath>
9383
</field>
@@ -99,12 +89,7 @@
9989
<field name="model">maintenance.request</field>
10090
<field name="inherit_id" ref="maintenance.hr_equipment_request_view_kanban" />
10191
<field name="arch" type="xml">
102-
<xpath expr="//*[hasclass('oe_kanban_bottom_left')]" position="inside">
103-
<field
104-
name="show_time_control"
105-
groups="hr_timesheet.group_hr_timesheet_user"
106-
invisible="1"
107-
/>
92+
<xpath expr="//footer//field[@name='activity_ids']" position="after">
10893
<a
10994
name="button_start_work"
11095
invisible="show_time_control != 'start'"
@@ -137,11 +122,6 @@
137122
/>
138123
<field name="arch" type="xml">
139124
<field name="timesheet_total_hours" position="after">
140-
<field
141-
name="show_time_control"
142-
groups="hr_timesheet.group_hr_timesheet_user"
143-
invisible="1"
144-
/>
145125
<button
146126
name="button_start_work"
147127
title="Start work"

0 commit comments

Comments
 (0)