From 029360264dc6959a86e5bb57fbc1f6d469765aaf Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Jan 2026 05:14:17 -0500 Subject: [PATCH 1/2] [FIX] hr_shift: reduce crash when missing data --- hr_shift/models/shift_planning.py | 7 ++++++- hr_shift/wizards/shift_planning_wizard.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hr_shift/models/shift_planning.py b/hr_shift/models/shift_planning.py index 5aad849..ecbeb2a 100644 --- a/hr_shift/models/shift_planning.py +++ b/hr_shift/models/shift_planning.py @@ -59,7 +59,12 @@ def default_get(self, fields_list): # Get the last plan and start from there result = super().default_get(fields_list) last_plan = self._get_last_plan() - if not last_plan or result.get("year") or result.get("week_number"): + if ( + not last_plan + or not last_plan.end_date + or result.get("year") + or result.get("week_number") + ): return result year, week_number, *_ = ( last_plan.end_date + relativedelta(days=1) diff --git a/hr_shift/wizards/shift_planning_wizard.py b/hr_shift/wizards/shift_planning_wizard.py index f12fee4..db031a0 100644 --- a/hr_shift/wizards/shift_planning_wizard.py +++ b/hr_shift/wizards/shift_planning_wizard.py @@ -43,8 +43,8 @@ def default_get(self, fields_list): result = super().default_get(fields_list) default_vals = self.env["hr.shift.planning"].default_get([]) result.update( - week_number=default_vals["week_number"], - year=default_vals["year"], + week_number=default_vals.get("week_number"), + year=default_vals.get("year"), ) if not result.get("from_planning_id"): result.update( From 877a47ba17b7d9cc57f41c70b85ffb4bc09d7d63 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 4 Feb 2026 08:56:02 -0500 Subject: [PATCH 2/2] [FIX] hr_shift: typo self --- hr_shift/models/shift_planning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hr_shift/models/shift_planning.py b/hr_shift/models/shift_planning.py index ecbeb2a..c0cbdc5 100644 --- a/hr_shift/models/shift_planning.py +++ b/hr_shift/models/shift_planning.py @@ -282,7 +282,7 @@ def _generate_shift_lines(self): ) shift.line_ids.create(shift_lines) - def create(Self, vals_list): + def create(self, vals_list): res = super().create(vals_list) res._generate_shift_lines() return res