diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index 6a68665dc04..e662b4366cf 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -94,8 +94,8 @@ class Project(models.Model): class Task(models.Model): _inherit = "project.task" - analytic_account_id = fields.Many2one('account.analytic.account', string="Analytic Account", related='project_id.analytic_account_id', readonly=True) - allow_timesheets = fields.Boolean("Allow timesheets", compute='_compute_allow_timesheets', help="Timesheets can be logged on this task.") + analytic_account_active = fields.Boolean("Analytic Account", related='project_id.analytic_account_id.active', readonly=True) + allow_timesheets = fields.Boolean("Allow timesheets", related='project_id.allow_timesheets', help="Timesheets can be logged on this task.") remaining_hours = fields.Float("Remaining Hours", compute='_compute_remaining_hours', inverse='_inverse_remaining_hours', help="Total remaining time, can be re-estimated periodically by the assignee of the task.") effective_hours = fields.Float("Hours Spent", compute='_compute_effective_hours', compute_sudo=True, store=True, help="Computed using the sum of the task work done.") total_hours_spent = fields.Float("Total Hours", compute='_compute_total_hours_spent', store=True, help="Computed as: Time Spent + Sub-tasks Hours.") @@ -103,11 +103,6 @@ class Task(models.Model): subtask_effective_hours = fields.Float("Sub-tasks Hours Spent", compute='_compute_subtask_effective_hours', store=True, help="Sum of actually spent hours on the subtask(s)", oldname='children_hours') timesheet_ids = fields.One2many('account.analytic.line', 'task_id', 'Timesheets') - @api.depends('project_id.allow_timesheets', 'project_id.analytic_account_id') - def _compute_allow_timesheets(self): - for task in self: - task.allow_timesheets = task.project_id.allow_timesheets and task.project_id.analytic_account_id.active - @api.depends('timesheet_ids.unit_amount') def _compute_effective_hours(self): for task in self: diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml index a98fd8e4624..a7b8bf0a74f 100644 --- a/addons/hr_timesheet/views/project_views.xml +++ b/addons/hr_timesheet/views/project_views.xml @@ -61,9 +61,9 @@ - + - + @@ -76,12 +76,12 @@ - + - + @@ -91,7 +91,7 @@ - +