summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorahta <ahta@odoo.com>2025-01-15 14:57:38 +0000
committerahta <ahta@odoo.com>2025-02-07 23:17:02 +0000
commit2a30ae85ece135cabea1c736f567164ff60f7f45 (patch)
tree987097883252f102d2bf3a6b899367479e2b983b
parentb183093b3d91e329ee304604718e402712aa8622 (diff)
[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) <yti@odoo.com>
-rw-r--r--addons/hr_holidays/tests/test_expiring_leaves.py2
-rw-r--r--addons/hr_holidays/views/hr_leave_allocation_views.xml4
-rw-r--r--addons/hr_holidays_attendance/i18n/hr_holidays_attendance.pot14
-rw-r--r--addons/hr_holidays_attendance/models/hr_leave_allocation.py4
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 @@
<div name="duration_display">
<field name="number_of_days_display" nolabel="1" style="width: 5rem;"
invisible="type_request_unit == 'hour'"
- readonly="0"/>
+ readonly="is_officer != True and state not in ('draft','confirm')"/>
<field name="number_of_hours_display" nolabel="1" style="width: 5rem;"
invisible="type_request_unit != 'hour'"
- readonly="0"/>
+ readonly="is_officer != True and state not in ('draft','confirm')"/>
<span class="ml8" invisible="type_request_unit == 'hour'">Days</span>
<span class="ml8" invisible="type_request_unit != 'hour'">Hours</span>
</div>
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"
@@ -111,6 +111,14 @@ msgid ""
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
msgid "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