diff --git a/portal_holidays/models/hr_leave_allocation.py b/portal_holidays/models/hr_leave_allocation.py index f7618f53..ca227121 100644 --- a/portal_holidays/models/hr_leave_allocation.py +++ b/portal_holidays/models/hr_leave_allocation.py @@ -1,6 +1,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class HolidaysAllocation(models.Model): @@ -9,3 +9,14 @@ class HolidaysAllocation(models.Model): employee_overtime = fields.Float( related="employee_id.total_overtime", groups="base.group_user,portal_holidays.group_portal_backend_holiday" ) + + @api.model_create_multi + def create(self, vals_list): + """ + Allows portal holidays users to create allocation records + and ensures proper follower subscriptions. + """ + if self.env.user.has_group("portal_holidays.group_portal_backend_holiday"): + self = self.sudo() + + return super(HolidaysAllocation, self).create(vals_list) # , self.with_context(mail_create_nosubscribe=True)