Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] portal_holidays: allow creating new leave allocation request #240

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions portal_holidays/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 40 additions & 1 deletion portal_holidays/models/hr_leave_allocation.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
29 changes: 29 additions & 0 deletions portal_holidays/views/hr_leave_allocation_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version='1.0' encoding='UTF-8' ?>
<odoo>
<!-- <record id="hr_leave_allocation_action_my_portal_holidays" model="ir.actions.act_window">
<field name="name">My Allocations (portal holidays)</field>
<field name="res_model">hr.leave.allocation</field>
<field name="view_mode">list,kanban</field>
<field name="search_view_id" ref="hr_holidays.hr_leave_allocation_view_search_my"/>
<field name="context">{'search_default_year': 1 , 'is_employee_allocation': True}</field>
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
<field name="groups_id" eval="[(4, ref('base.group_user'))]"/>
</record> -->
<!--
<record id="hr_leave_allocation_action_my" model="ir.actions.act_window">
<field name="groups_id" eval="[(4, ref('base.group_user'))]"/>
</record> -->

<record id="hr_leave_allocation_view_tree_my_portal_holiday" model="ir.ui.view">
<field name="name">hr.leave.allocation.view.list.my.portal.holiday</field>
<field name="model">hr.leave.allocation</field>
<field name="inherit_id" ref="hr_holidays.hr_leave_allocation_view_tree_my"/>
<field name="arch" type="xml">
<xpath expr="//list" position="attributes">
<attribute name="edit">false</attribute>
</xpath>

</field>
</record>

</odoo>
Loading