From e9127a9fdffad3281548eb2774871d0d58114a92 Mon Sep 17 00:00:00 2001 From: "Hugo Carlier (Huca)" Date: Wed, 6 Dec 2023 11:09:09 +0100 Subject: [PATCH] [FIX] project: remove onchange on date/date_end for projects Steps ===== - Install module project - Open the form view of a project - Set a planned date - Click anywhere on the page to remove the focus from the date picker Issue ===== The chosen date disappeared without any explanation to the user Cause ===== odoo#123268 introduced some changes related to the planned dates of projects. 1. the write method is modified to avoid the write of only a start/end date (both date should be set or none of them) 2. a required is added on the start date field in the form view of project 3. an onchange is added to avoid to have one of both field set and not the other This last change is problematic as it overrides the required behavior of the date fields. On top of that, https://github.com/odoo/odoo/pull/143509 changed the behavior of the datepicker widget that only display the full range by default if both fields are required (which is not the case here if they are empty). The combination of those changes have the consequence that the planned date field is unusable in the form view of projects. Fix === The onchange being only useful in form view, it is deprecated as the required attribute is sufficient for this usecase and provide the user warnings if he forget a field. On top of that a required attribute is also set on the end date field. task-3628069 closes odoo/odoo#145167 Related: odoo/enterprise#52280 Signed-off-by: Julien Mougenot (jum) --- addons/project/models/project_project.py | 6 ++---- addons/project/views/project_project_views.xml | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/addons/project/models/project_project.py b/addons/project/models/project_project.py index 10653d414bb..bd4441c8bbc 100644 --- a/addons/project/models/project_project.py +++ b/addons/project/models/project_project.py @@ -378,12 +378,10 @@ class Project(models.Model): else: project.access_instruction_message = '' + # TODO: Remove in master @api.onchange('date_start', 'date') def _onchange_planned_date(self): - if not self.date and self.date_start: - self.date_start = False - elif not self.date_start and self.date: - self.date = False + return @api.model def _map_tasks_default_valeus(self, task, project): diff --git a/addons/project/views/project_project_views.xml b/addons/project/views/project_project_views.xml index 526a87ef948..48c8e23c569 100644 --- a/addons/project/views/project_project_views.xml +++ b/addons/project/views/project_project_views.xml @@ -87,8 +87,8 @@ - - + + @@ -230,8 +230,7 @@ - - +