diff --git a/portal_holidays/__manifest__.py b/portal_holidays/__manifest__.py index 1da9857a..7c41f617 100644 --- a/portal_holidays/__manifest__.py +++ b/portal_holidays/__manifest__.py @@ -34,6 +34,7 @@ "security/ir.model.access.csv", "views/base_menus.xml", "views/hr_employee_views.xml", + "views/hr_leave_allocation_views.xml", ], "demo": [ "demo/hr_demo.xml", diff --git a/portal_holidays/models/hr_leave_allocation.py b/portal_holidays/models/hr_leave_allocation.py index f7618f53..7f500f6d 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,42 @@ 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) + + # @api.model + # def get_view(self, view_id=None, view_type='form', **options): + # result = super().get_view(view_id, view_type, **options) + # # if ( + # # self.env.user.has_group( + # # "portal_holidays.group_portal_backend_holiday" + # # ) + # # ): + # # if view_type == "list": + # arch = etree.fromstring(result["arch"]) + # for node in arch.xpath("//form"): + # node.set("edit", "false") # Disable inline editing + # node.set("create", "false") # Disable create + # node.set("delete", "false") # Disable delete + # node.set("selectable", "false") # Disable delete + # result["arch"] = etree.tostring(arch, encoding="unicode") + # return result + + # @api.model + # def _get_view(self, view_id=None, view_type="list", **options): + # arch, view = super()._get_view(view_id, view_type, **options) + # if view_type == "list" and self.env.user.has_group("portal_holidays.group_portal_backend_holiday"): + # fields = arch.xpath("//list") + # for node in fields: + # node.set("edit", "false") + # # node.set("selectable", "false") + # return arch, view diff --git a/portal_holidays/views/hr_leave_allocation_views.xml b/portal_holidays/views/hr_leave_allocation_views.xml new file mode 100644 index 00000000..3713ab0a --- /dev/null +++ b/portal_holidays/views/hr_leave_allocation_views.xml @@ -0,0 +1,29 @@ + + + + + + + hr.leave.allocation.view.list.my.portal.holiday + hr.leave.allocation + + + + false + + + + + +