From 2a30ae85ece135cabea1c736f567164ff60f7f45 Mon Sep 17 00:00:00 2001 From: ahta Date: Wed, 15 Jan 2025 14:57:38 +0000 Subject: [FIX] hr_*: allow editing unapproved allocation requests *: holidays,holidays_attendance The base.group_user did not have the access right to read overtime_id, which is necessary for filtering allocations that do not have a null overtime_id. The access right was granted to base.group_user only when the allocation state is either draft or confirm. In the test_expiration_date_2 the user needed to be a user_hruser to have the access rights to edit the number_of_days. task-4452360 closes odoo/odoo#196815 X-original-commit: 2bb61e4d534d23bf81a0b36f6ffcc27c0f6a6a0b Signed-off-by: Yannick Tivisse (yti) --- addons/hr_holidays/tests/test_expiring_leaves.py | 2 +- addons/hr_holidays/views/hr_leave_allocation_views.xml | 4 ++-- .../hr_holidays_attendance/i18n/hr_holidays_attendance.pot | 14 +++++++++++--- .../hr_holidays_attendance/models/hr_leave_allocation.py | 4 +++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/addons/hr_holidays/tests/test_expiring_leaves.py b/addons/hr_holidays/tests/test_expiring_leaves.py index 639bcf7b8f6..983466dbcb5 100644 --- a/addons/hr_holidays/tests/test_expiring_leaves.py +++ b/addons/hr_holidays/tests/test_expiring_leaves.py @@ -468,7 +468,7 @@ class TestExpiringLeaves(HttpCase, TestHrHolidaysCommon): }) with freeze_time("2024-1-1"): - self.env['hr.leave.allocation'].sudo()._update_accrual() + self.env['hr.leave.allocation'].with_user(self.user_hruser)._update_accrual() target_date = date(2024, 1, 1) allocation_data = self.leave_type.get_allocation_data(logged_in_emp, target_date) diff --git a/addons/hr_holidays/views/hr_leave_allocation_views.xml b/addons/hr_holidays/views/hr_leave_allocation_views.xml index be40ca564cd..6c998410b81 100644 --- a/addons/hr_holidays/views/hr_leave_allocation_views.xml +++ b/addons/hr_holidays/views/hr_leave_allocation_views.xml @@ -154,10 +154,10 @@
+ readonly="is_officer != True and state not in ('draft','confirm')"/> + readonly="is_officer != True and state not in ('draft','confirm')"/> Days Hours
diff --git a/addons/hr_holidays_attendance/i18n/hr_holidays_attendance.pot b/addons/hr_holidays_attendance/i18n/hr_holidays_attendance.pot index 43bca44e311..b509a57f75e 100644 --- a/addons/hr_holidays_attendance/i18n/hr_holidays_attendance.pot +++ b/addons/hr_holidays_attendance/i18n/hr_holidays_attendance.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 18.0\n" +"Project-Id-Version: Odoo Server 18.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-26 08:55+0000\n" -"PO-Revision-Date: 2024-09-26 08:55+0000\n" +"POT-Creation-Date: 2025-02-06 14:58+0000\n" +"PO-Revision-Date: 2025-02-06 14:58+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -110,6 +110,14 @@ msgid "" " deducted." msgstr "" +#. module: hr_holidays_attendance +#. odoo-python +#: code:addons/hr_holidays_attendance/models/hr_leave_allocation.py:0 +msgid "" +"Only an Officer or Administrator is allowed to edit the allocation duration " +"in this status." +msgstr "" + #. module: hr_holidays_attendance #: model:ir.model.fields,field_description:hr_holidays_attendance.field_hr_leave__overtime_deductible #: model:ir.model.fields,field_description:hr_holidays_attendance.field_hr_leave_allocation__overtime_deductible diff --git a/addons/hr_holidays_attendance/models/hr_leave_allocation.py b/addons/hr_holidays_attendance/models/hr_leave_allocation.py index 1b962540e9f..2732fd5e4b8 100644 --- a/addons/hr_holidays_attendance/models/hr_leave_allocation.py +++ b/addons/hr_holidays_attendance/models/hr_leave_allocation.py @@ -52,7 +52,9 @@ class HolidaysAllocation(models.Model): res = super().write(vals) if 'number_of_days' not in vals: return res - for allocation in self.filtered('overtime_id'): + if not self.env.user.has_group("hr_holidays.group_hr_holidays_user") and any(allocation.state not in ('draft', 'confirm') for allocation in self): + raise ValidationError(_('Only an Officer or Administrator is allowed to edit the allocation duration in this status.')) + for allocation in self.sudo().filtered('overtime_id'): employee = allocation.employee_id duration = allocation.number_of_hours_display overtime_duration = allocation.overtime_id.sudo().duration -- cgit v1.2.3