From ec72af71ac8399546dcaa131874c2b2c41098137 Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux Date: Thu, 12 Mar 2026 12:18:42 +0100 Subject: [PATCH 1/3] remove time_control from helpdesk_timesheet --- helpdesk_mgmt_timesheet/__manifest__.py | 1 - .../models/helpdesk_ticket.py | 27 +--- helpdesk_mgmt_timesheet/tests/__init__.py | 1 - .../test_helpdesk_timesheet_time_control.py | 104 -------------- .../views/helpdesk_ticket_view.xml | 136 +----------------- helpdesk_mgmt_timesheet/wizards/__init__.py | 1 - .../wizards/hr_timesheet_switch.py | 27 ---- 7 files changed, 2 insertions(+), 295 deletions(-) delete mode 100644 helpdesk_mgmt_timesheet/tests/test_helpdesk_timesheet_time_control.py delete mode 100644 helpdesk_mgmt_timesheet/wizards/hr_timesheet_switch.py diff --git a/helpdesk_mgmt_timesheet/__manifest__.py b/helpdesk_mgmt_timesheet/__manifest__.py index 25c86322d7..fbb1ca0b19 100644 --- a/helpdesk_mgmt_timesheet/__manifest__.py +++ b/helpdesk_mgmt_timesheet/__manifest__.py @@ -19,7 +19,6 @@ "depends": [ "helpdesk_mgmt_project", "hr_timesheet", - "project_timesheet_time_control", ], "data": [ "views/helpdesk_ticket_templates.xml", diff --git a/helpdesk_mgmt_timesheet/models/helpdesk_ticket.py b/helpdesk_mgmt_timesheet/models/helpdesk_ticket.py index 78adeee044..251b53b6c2 100644 --- a/helpdesk_mgmt_timesheet/models/helpdesk_ticket.py +++ b/helpdesk_mgmt_timesheet/models/helpdesk_ticket.py @@ -6,7 +6,7 @@ class HelpdeskTicket(models.Model): _name = "helpdesk.ticket" - _inherit = ["helpdesk.ticket", "hr.timesheet.time_control.mixin"] + _inherit = ["helpdesk.ticket"] @api.model def _relation_with_timesheet_line(self): @@ -76,28 +76,3 @@ def _compute_last_timesheet_activity(self): record.timesheet_ids and record.timesheet_ids.sorted(key="date", reverse=True)[0].date ) or False - - @api.depends( - "team_id.allow_timesheet", - "project_id.allow_timesheets", - "timesheet_ids.employee_id", - "timesheet_ids.unit_amount", - ) - def _compute_show_time_control(self): - result = super()._compute_show_time_control() - for ticket in self: - if not ( - ticket.project_id.allow_timesheets and ticket.team_id.allow_timesheet - ): - ticket.show_time_control = False - return result - - def button_start_work(self): - result = super().button_start_work() - result["context"].update( - { - "default_project_id": self.project_id.id, - "default_task_id": self.task_id.id, - } - ) - return result diff --git a/helpdesk_mgmt_timesheet/tests/__init__.py b/helpdesk_mgmt_timesheet/tests/__init__.py index cd8409ca6d..37e6c48197 100644 --- a/helpdesk_mgmt_timesheet/tests/__init__.py +++ b/helpdesk_mgmt_timesheet/tests/__init__.py @@ -3,4 +3,3 @@ ############################################################################### from . import test_helpdesk_mgmt_timesheet from . import test_helpdesk_portal -from . import test_helpdesk_timesheet_time_control diff --git a/helpdesk_mgmt_timesheet/tests/test_helpdesk_timesheet_time_control.py b/helpdesk_mgmt_timesheet/tests/test_helpdesk_timesheet_time_control.py deleted file mode 100644 index 19aa75d9cd..0000000000 --- a/helpdesk_mgmt_timesheet/tests/test_helpdesk_timesheet_time_control.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright 2016-2018 Tecnativa - Pedro M. Baeza -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 - -from datetime import datetime, timedelta - -from odoo import exceptions -from odoo.tests import common - - -class TestHelpdeskTimesheetTimeControl(common.TransactionCase): - def setUp(self): - super().setUp() - admin = self.browse_ref("base.user_admin") - # Stop any timer running - self.env["account.analytic.line"].search( - [ - ("date_time", "!=", False), - ("user_id", "=", admin.id), - ("project_id.allow_timesheets", "=", True), - ("unit_amount", "=", 0), - ] - ).button_end_work() - admin.groups_id |= self.browse_ref("hr_timesheet.group_hr_timesheet_user") - self.uid = admin.id - self.project = self.env["project.project"].create( - {"name": "Test project", "allow_timesheets": True} - ) - self.project_without_timesheets = self.env["project.project"].create( - {"name": "Test project", "allow_timesheets": False} - ) - self.analytic_account = self.project.account_id - self.task = self.env["project.task"].create( - {"name": "Test task", "project_id": self.project.id} - ) - team_id = self.env["helpdesk.ticket.team"].create( - { - "name": "Team 1", - "allow_timesheet": True, - "default_project_id": self.project.id, - } - ) - self.ticket = self.env["helpdesk.ticket"].create( - { - "name": "Test Ticket", - "team_id": team_id.id, - "project_id": self.project.id, - "description": "Test ticket description", - "user_id": self.uid, - } - ) - self.ticket_line = self.env["account.analytic.line"].create( - { - "date_time": datetime.now() - timedelta(hours=1), - "ticket_id": self.ticket.id, - "project_id": self.project.id, - "account_id": self.analytic_account.id, - "name": "Test Ticket Timesheet line", - "user_id": self.uid, - } - ) - - def _create_wizard(self, action, active_record): - """Create a new hr.timesheet.switch wizard in the specified context. - :param dict action: Action definition that creates the wizard. - :param active_record: Record being browsed when creating the wizard. - """ - 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({}) - ) - - def test_ticket_time_control_flow(self): - """Test project.task time controls.""" - # Running line found, stop the timer - self.assertEqual(self.ticket.show_time_control, "stop") - self.ticket.button_end_work() - # No more running lines, cannot stop again - with self.assertRaises(exceptions.UserError): - self.ticket.button_end_work() - # All lines stopped, start new one - self.ticket.invalidate_recordset() - self.assertEqual(self.ticket.show_time_control, "start") - start_action = self.ticket.button_start_work() - wizard = self._create_wizard(start_action, self.ticket_line) - self.assertLessEqual(wizard.date_time, datetime.now()) - self.assertEqual(wizard.name, self.ticket_line.name) - self.assertEqual(wizard.project_id, self.ticket.project_id) - 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_ids) - self.assertEqual(new_line.project_id, self.project) - self.assertEqual(new_line.ticket_id, self.ticket) - self.assertEqual(new_line.unit_amount, 0) - self.assertTrue(self.ticket_line.unit_amount) diff --git a/helpdesk_mgmt_timesheet/views/helpdesk_ticket_view.xml b/helpdesk_mgmt_timesheet/views/helpdesk_ticket_view.xml index 4812774ddf..b5477e5380 100644 --- a/helpdesk_mgmt_timesheet/views/helpdesk_ticket_view.xml +++ b/helpdesk_mgmt_timesheet/views/helpdesk_ticket_view.xml @@ -56,30 +56,6 @@ groups="hr_timesheet.group_hr_timesheet_user" /> - -