diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py
index 6eea1f57c41..96ba98a2431 100644
--- a/addons/hr_timesheet/models/hr_timesheet.py
+++ b/addons/hr_timesheet/models/hr_timesheet.py
@@ -63,6 +63,7 @@ class AccountAnalyticLine(models.Model):
manager_id = fields.Many2one('hr.employee', "Manager", related='employee_id.parent_id', store=True)
encoding_uom_id = fields.Many2one('uom.uom', compute='_compute_encoding_uom_id')
partner_id = fields.Many2one(compute='_compute_partner_id', store=True, readonly=False)
+ readonly_timesheet = fields.Boolean(string="Readonly Timesheet", compute="_compute_readonly_timesheet")
def name_get(self):
result = super().name_get()
@@ -82,6 +83,16 @@ class AccountAnalyticLine(models.Model):
timesheet_dict = {res['id']: _get_display_name(res['project_id'], res['task_id']) for res in timesheets_read}
return list({**dict(result), **timesheet_dict}.items())
+ def _is_readonly(self):
+ self.ensure_one()
+ # is overridden in other timesheet related modules
+ return False
+
+ def _compute_readonly_timesheet(self):
+ readonly_timesheets = self.filtered(lambda timesheet: timesheet._is_readonly())
+ readonly_timesheets.readonly_timesheet = True
+ (self - readonly_timesheets).readonly_timesheet = False
+
def _compute_encoding_uom_id(self):
for analytic_line in self:
analytic_line.encoding_uom_id = analytic_line.company_id.timesheet_encode_uom_id
diff --git a/addons/hr_timesheet/views/hr_timesheet_views.xml b/addons/hr_timesheet/views/hr_timesheet_views.xml
index 13080293ac8..379931a88ec 100644
--- a/addons/hr_timesheet/views/hr_timesheet_views.xml
+++ b/addons/hr_timesheet/views/hr_timesheet_views.xml
@@ -5,13 +5,14 @@
account.analytic.line.tree.hr_timesheet
account.analytic.line
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -120,15 +121,18 @@
-
-
-
+
+
+
+
-
+
-
+
@@ -146,7 +150,7 @@
10
-
+
diff --git a/addons/hr_timesheet/views/project_task_views.xml b/addons/hr_timesheet/views/project_task_views.xml
index 39cf7ac4bcb..694e08a97b2 100644
--- a/addons/hr_timesheet/views/project_task_views.xml
+++ b/addons/hr_timesheet/views/project_task_views.xml
@@ -40,12 +40,15 @@
-
-
+
+
+
-
-
-
+
+
+
@@ -86,11 +89,14 @@
@@ -59,7 +59,7 @@
-
+
diff --git a/addons/sale_timesheet/views/project_task_views.xml b/addons/sale_timesheet/views/project_task_views.xml
index 05ad66e377d..682037544ba 100644
--- a/addons/sale_timesheet/views/project_task_views.xml
+++ b/addons/sale_timesheet/views/project_task_views.xml
@@ -126,10 +126,6 @@
project.task
-
-
- timesheet_invoice_id != False
-
@@ -149,12 +145,12 @@