[FIX] hr_timesheet: fix traceback on deleting tasks
Steps to reproduce ------------------ 1. Install hr_timesheet. 2. Try deleting a task. You will get a traceback. Explanation ----------- In https://github.com/odoo/odoo/pull/110737, the calls to `_read_group` were adapted to the new API, but a slight mistake was introduced when adapting the code in `_unlink_except_contains_entries`. This commit fixes it. closes odoo/odoo#123597 X-original-commit: 83046fb1fd00ffde7568c35c76697ecf7f4db8fa Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
@@ -224,7 +224,7 @@ class Task(models.Model):
|
||||
[('task_id', 'in', self.ids)],
|
||||
['task_id'],
|
||||
)
|
||||
task_with_timesheets_ids = [task.id for task in timesheet_data]
|
||||
task_with_timesheets_ids = [task.id for task, in timesheet_data]
|
||||
if task_with_timesheets_ids:
|
||||
if len(task_with_timesheets_ids) > 1:
|
||||
warning_msg = _("These tasks have some timesheet entries referencing them. Before removing these tasks, you have to remove these timesheet entries.")
|
||||
|
||||
@@ -5,7 +5,7 @@ from lxml import etree
|
||||
|
||||
from odoo.fields import Command
|
||||
from odoo.tests.common import TransactionCase, Form
|
||||
from odoo.exceptions import AccessError, UserError, ValidationError
|
||||
from odoo.exceptions import AccessError, RedirectWarning, UserError, ValidationError
|
||||
|
||||
|
||||
class TestCommonTimesheet(TransactionCase):
|
||||
@@ -596,3 +596,15 @@ class TestTimesheet(TestCommonTimesheet):
|
||||
self.env.company.timesheet_encode_uom_id = self.env.ref('uom.product_uom_day')
|
||||
self.assertEqual(project.total_timesheet_time, 8, "Total timesheet time should be 8 hours")
|
||||
self.assertEqual(project.timesheet_encode_uom_id.name, 'Days', "Timesheet encode uom should be 'Days'")
|
||||
|
||||
def test_unlink_task_with_timesheet(self):
|
||||
self.env['account.analytic.line'].create({
|
||||
'project_id': self.project_customer.id,
|
||||
'task_id': self.task1.id,
|
||||
'name': 'timesheet',
|
||||
'unit_amount': 4,
|
||||
'employee_id': self.empl_employee.id,
|
||||
})
|
||||
self.task2.unlink()
|
||||
with self.assertRaises(RedirectWarning):
|
||||
self.task1.unlink()
|
||||
|
||||
Reference in New Issue
Block a user