Skip to content

Conversation

@Alexgars73
Copy link
Contributor

No description provided.

@Alexgars73 Alexgars73 force-pushed the 18.0-mig-maintenance_timesheet_time_control branch 2 times, most recently from 8f0c59c to 606674d Compare April 24, 2025 09:26
@Alexgars73 Alexgars73 force-pushed the 18.0-mig-maintenance_timesheet_time_control branch from 606674d to a07461b Compare May 7, 2025 13:49
Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the title to: [18.0][MIG] maintenance_timesheet_time_control: Migration to 18.0 and rebase so we can check it functionally.

@victoralmau
Copy link
Member

maintenance_timesheet is already merged, so you can now delete the commit test-requirements.txt

@Alexgars73 Alexgars73 changed the title 18.0-mig-maintenance_timesheet_time_control [18.0][MIG] maintenance_timesheet_time_control: Migration to 18.0 Jun 25, 2025
victoralmau and others added 15 commits June 25, 2025 08:11
TT40881

[UPD] Update maintenance_timesheet_time_control.pot

[UPD] README.rst
…ree from maintenance request for view

TT40881

[UPD] Update maintenance_timesheet_time_control.pot

maintenance_timesheet_time_control 13.0.1.1.0

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: maintenance-13.0/maintenance-13.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet_time_control/
TT40942

[UPD] Update maintenance_timesheet_time_control.pot

[UPD] README.rst
TT40942

maintenance_timesheet_time_control

maintenance_timesheet_time_control

[UPD] Update maintenance_timesheet_time_control.pot

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/
Translated using Weblate (Italian)

Currently translated at 100.0% (8 of 8 strings)

Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings)

Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings)

Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/es/

[UPD] README.rst
Currently translated at 100.0% (8 of 8 strings)

Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings)

Translation: maintenance-17.0/maintenance-17.0-maintenance_timesheet_time_control
Translate-URL: https://translation.odoo-community.org/projects/maintenance-17-0/maintenance-17-0-maintenance_timesheet_time_control/it/
@Alexgars73 Alexgars73 force-pushed the 18.0-mig-maintenance_timesheet_time_control branch 2 times, most recently from 208da58 to 6490147 Compare June 25, 2025 06:12
@Alexgars73
Copy link
Contributor Author

@victoralmau Done!

@victoralmau
Copy link
Member

Thanks, can you add similar changes to OCA/timesheet@6c2cf12 in the tests of this module?

@Alexgars73
Copy link
Contributor Author

Thanks, can you add similar changes to OCA/timesheet@6c2cf12 in the tests of this module?

What do you mean?

Comment on lines 14 to 18
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>

It is not necessary to add the field, odoo will automatically add it to the view as invisible automatically.

Also, in list views, it should be column_invisible=1, but better to remove the field and reduce code.

Comment on lines 64 to 68
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>

Comment on lines 103 to 107
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>

Comment on lines 140 to 144
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field
name="show_time_control"
groups="hr_timesheet.group_hr_timesheet_user"
invisible="1"
/>

Comment on lines 9 to 33
from odoo.addons.base.tests.common import BaseCommon


class TestMaintenanceTimesheetTimeControl(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = new_test_user(
cls.env,
login="test-maintenance-user",
groups="maintenance.group_equipment_manager,"
"hr_timesheet.group_hr_timesheet_user",
)
cls.user.action_create_employee()
cls.project = cls.env["project.project"].create(
{"name": "Test project", "allow_timesheets": True}
)
cls.category = cls.env["maintenance.equipment.category"].create(
{"name": "Test category"}
)
cls.team = cls.env["maintenance.team"].create({"name": "Test team"})
cls.equipment = cls.env["maintenance.equipment"].create(
{
"name": "Test computer",
"category_id": cls.category.id,
"project_id": cls.project.id,
"maintenance_team_id": cls.team.id,
}
)

def _create_analytic_line(self, request):
return self.env["account.analytic.line"].create(
{
"date_time": datetime.now() - timedelta(hours=1),
"maintenance_request_id": request.id,
"project_id": request.project_id.id,
"account_id": request.project_id.account_id.id,
"name": "Test Maintenance Request Timesheet line",
"user_id": self.env.user.id,
}
)

def _create_wizard(self, action, active_record):
self.assertEqual(action["res_model"], "hr.timesheet.switch")
self.assertEqual(action["target"], "new")
self.assertEqual(action["type"], "ir.actions.act_window")
self.assertEqual(action["view_mode"], "form")
return (
active_record.env[action["res_model"]]
.with_context(
active_id=active_record.id,
active_ids=active_record.ids,
active_model=active_record._name,
**action.get("context", {}),
)
.create({})
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from odoo.addons.base.tests.common import BaseCommon
class TestMaintenanceTimesheetTimeControl(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = new_test_user(
cls.env,
login="test-maintenance-user",
groups="maintenance.group_equipment_manager,"
"hr_timesheet.group_hr_timesheet_user",
)
cls.user.action_create_employee()
cls.project = cls.env["project.project"].create(
{"name": "Test project", "allow_timesheets": True}
)
cls.category = cls.env["maintenance.equipment.category"].create(
{"name": "Test category"}
)
cls.team = cls.env["maintenance.team"].create({"name": "Test team"})
cls.equipment = cls.env["maintenance.equipment"].create(
{
"name": "Test computer",
"category_id": cls.category.id,
"project_id": cls.project.id,
"maintenance_team_id": cls.team.id,
}
)
def _create_analytic_line(self, request):
return self.env["account.analytic.line"].create(
{
"date_time": datetime.now() - timedelta(hours=1),
"maintenance_request_id": request.id,
"project_id": request.project_id.id,
"account_id": request.project_id.account_id.id,
"name": "Test Maintenance Request Timesheet line",
"user_id": self.env.user.id,
}
)
def _create_wizard(self, action, active_record):
self.assertEqual(action["res_model"], "hr.timesheet.switch")
self.assertEqual(action["target"], "new")
self.assertEqual(action["type"], "ir.actions.act_window")
self.assertEqual(action["view_mode"], "form")
return (
active_record.env[action["res_model"]]
.with_context(
active_id=active_record.id,
active_ids=active_record.ids,
active_model=active_record._name,
**action.get("context", {}),
)
.create({})
)
from odoo.addons.project_timesheet_time_control.tests import (
test_project_timesheet_time_control,
)
class TestMaintenanceTimesheetTimeControl(
test_project_timesheet_time_control.TestProjectTimesheetTimeControlBase
):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user.groups_id |= cls.env.ref("maintenance.group_equipment_manager")
cls.category = cls.env["maintenance.equipment.category"].create(
{"name": "Test category"}
)
cls.team = cls.env["maintenance.team"].create({"name": "Test team"})
cls.equipment = cls.env["maintenance.equipment"].create(
{
"name": "Test computer",
"category_id": cls.category.id,
"project_id": cls.project.id,
"maintenance_team_id": cls.team.id,
}
)
cls.request = cls.env["maintenance.request"].create(
{"name": "Test computer request", "equipment_id": self.equipment.id}
)
cls.line.maintenance_request_id = cls.request

Comment on lines 67 to 96
@users("test-maintenance-user")
def test_maintenance_request_time_control_flow(self):
request = self.env["maintenance.request"].create(
{"name": "Test computer request", "equipment_id": self.equipment.id}
)
analytic_line = self._create_analytic_line(request)
# Running line found, stop the timer
self.assertEqual(request.show_time_control, "stop")
request.button_end_work()
# No more running lines, cannot stop again
with self.assertRaises(exceptions.UserError):
request.button_end_work()
# All lines stopped, start new one
self.assertEqual(request.show_time_control, "start")
start_action = request.button_start_work()
wizard = self._create_wizard(start_action, request)
self.assertLessEqual(wizard.date_time, datetime.now())
self.assertEqual(wizard.name, analytic_line.name)
self.assertEqual(wizard.project_id, request.project_id)
self.assertEqual(
wizard.analytic_line_id.account_id, request.project_id.account_id
)
self.assertEqual(wizard.analytic_line_id, analytic_line)
new_act = wizard.with_context(show_created_timer=True).action_switch()
new_line = self.env[new_act["res_model"]].browse(new_act["res_id"])
self.assertEqual(new_line.employee_id, self.env.user.employee_id)
self.assertEqual(new_line.project_id, self.project)
self.assertEqual(new_line.maintenance_request_id, request)
self.assertEqual(new_line.unit_amount, 0)
self.assertTrue(analytic_line.unit_amount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@users("test-maintenance-user")
def test_maintenance_request_time_control_flow(self):
request = self.env["maintenance.request"].create(
{"name": "Test computer request", "equipment_id": self.equipment.id}
)
analytic_line = self._create_analytic_line(request)
# Running line found, stop the timer
self.assertEqual(request.show_time_control, "stop")
request.button_end_work()
# No more running lines, cannot stop again
with self.assertRaises(exceptions.UserError):
request.button_end_work()
# All lines stopped, start new one
self.assertEqual(request.show_time_control, "start")
start_action = request.button_start_work()
wizard = self._create_wizard(start_action, request)
self.assertLessEqual(wizard.date_time, datetime.now())
self.assertEqual(wizard.name, analytic_line.name)
self.assertEqual(wizard.project_id, request.project_id)
self.assertEqual(
wizard.analytic_line_id.account_id, request.project_id.account_id
)
self.assertEqual(wizard.analytic_line_id, analytic_line)
new_act = wizard.with_context(show_created_timer=True).action_switch()
new_line = self.env[new_act["res_model"]].browse(new_act["res_id"])
self.assertEqual(new_line.employee_id, self.env.user.employee_id)
self.assertEqual(new_line.project_id, self.project)
self.assertEqual(new_line.maintenance_request_id, request)
self.assertEqual(new_line.unit_amount, 0)
self.assertTrue(analytic_line.unit_amount)
@users("test-user")
def test_maintenance_request_time_control_flow(self):
# Running line found, stop the timer
self.assertEqual(request.show_time_control, "stop")
request.button_end_work()
# No more running lines, cannot stop again
with self.assertRaises(exceptions.UserError):
request.button_end_work()
# All lines stopped, start new one
self.assertEqual(self.request.show_time_control, "start")
start_action = self.request.button_start_work()
wizard = self._create_wizard(start_action, self.request)
self.assertLessEqual(wizard.date_time, fields.Datetime.now())
self.assertEqual(wizard.name, self.line.name)
self.assertEqual(wizard.project_id, self.request.project_id)
self.assertEqual(
wizard.analytic_line_id.account_id, self.request.project_id.account_id
)
self.assertEqual(wizard.analytic_line_id, self.line)
new_act = wizard.with_context(show_created_timer=True).action_switch()
new_line = self.env[new_act["res_model"]].browse(new_act["res_id"])
self.assertEqual(new_line.employee_id, self.env.user.employee_id)
self.assertEqual(new_line.project_id, self.project)
self.assertEqual(new_line.maintenance_request_id, self.request)
self.assertEqual(new_line.unit_amount, 0)
self.assertTrue(self.line.unit_amount)

@Alexgars73 Alexgars73 force-pushed the 18.0-mig-maintenance_timesheet_time_control branch 2 times, most recently from 4c80d37 to 3b27f5d Compare July 1, 2025 10:40
@Alexgars73
Copy link
Contributor Author

@victoralmau Done! If you can review it.

expr="//field[@name='timesheet_ids']/list//field[@name='date']"
position="attributes"
>
<attribute name="invisible">1</attribute>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<attribute name="invisible">1</attribute>
<attribute name="column_invisible">1</attribute>

@victoralmau
Copy link
Member

Superseded by #498

@pedrobaeza
Copy link
Member

If there's only one last change to do, let's see if @Alexgars73 can do it. Anyway, the attribution is preserved in the other PR though.

@Alexgars73 Alexgars73 force-pushed the 18.0-mig-maintenance_timesheet_time_control branch from 3b27f5d to 01d5c38 Compare July 8, 2025 10:34
@Alexgars73
Copy link
Contributor Author

@victoralmau @pedrobaeza Done!.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ocabot migration maintenance_timesheet_time_control
/ocabot merge nobump

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Jul 8, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Jul 8, 2025
16 tasks
@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-487-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit f26fe23 into OCA:18.0 Jul 8, 2025
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at cc57277. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants