[FIX] hr_timesheet: remove display_name compute dependencies

Steps to reproduce issue:

1. In settings, activate Timesheets
2. Go to _Project > Tasks > All Tasks_
3. Create a new task
4. Give the task a title
5. Choose an Assignee
6. The title disappeared

Explanation:

The title field, `display_name`, is a computed field that gets its value from `name`. This compute has dependencies coming from other computed values. Those dependencies lead to other dependencies up to `project_id`. Because of it, changing `project_id` will trigger `_compute_display_name`.

Suggested fix:

Backporting odoo/odoo@8178ad79bb, the cause of the issue is the same.

opw-3823040

closes odoo/odoo#161276

X-original-commit: 89b1ff812ecd4186f2196341d72fe7e6380404dd
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Stroobant Paul (stpa) <stpa@odoo.com>
This commit is contained in:
Paul Stroobant
2024-04-11 05:21:48 +00:00
parent 2d79430e18
commit bff38ae366
2 changed files with 6 additions and 1 deletions
@@ -199,7 +199,6 @@ class Task(models.Model):
# Is override in sale_timesheet
return self.timesheet_ids
@api.depends('allow_timesheets', 'allocated_hours', 'encode_uom_in_days', 'remaining_hours')
@api.depends_context('hr_timesheet_display_remaining_hours')
def _compute_display_name(self):
super()._compute_display_name()
@@ -37,3 +37,9 @@ class TestProjectTaskQuickCreate(TestCommonTimesheet):
task = task_form.save()
results = (task.name, len(task.tag_ids), len(task.user_ids), task.priority, task.allocated_hours)
self.assertEqual(results, (expression, 0, 0, '0', 0))
def test_create_task_and_add_project(self):
task_form = Form(self.env['project.task'].with_context({'tracking_disable': True}), view="project.quick_create_task_form")
task_form.display_name = 'hello'
task_form.project_id = self.project_customer
self.assertEqual(task_form.display_name, 'hello')