-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] #3 show hours with float_time widget, make numbers links
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import hr_attendance | ||
from . import hr_leave_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2023 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class HrLeaveType(models.Model): | ||
_inherit = "hr.leave.type" | ||
|
||
def _get_days_request(self): | ||
"""Add a formatted version for every field used in calendar header""" | ||
result = super()._get_days_request() | ||
for key in ("virtual_leaves_taken", "virtual_remaining_leaves"): | ||
if result[1]["request_unit"] == "hour": | ||
formatted = self.env["ir.qweb.field.float_time"].value_to_html( | ||
float(result[1][key]), {} | ||
) | ||
else: | ||
# TODO: this also applies to half days, do something? | ||
formatted = result[1][key] | ||
result[1]["%s_formatted" % key] = formatted | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf8" ?> | ||
<templates> | ||
<t t-inherit="hr_holidays.dashboard_calendar_header"> | ||
<xpath | ||
expr="//span[@t-esc="timeoff[1]['virtual_remaining_leaves']"]" | ||
position="attributes" | ||
> | ||
<attribute name="t-esc"> | ||
timeoff[1]['virtual_remaining_leaves_formatted'] | ||
</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//t[@t-elif='requires_allocation']/span[@t-esc="timeoff[1]['virtual_remaining_leaves']"]" | ||
position="before" | ||
> | ||
<!-- TODO: we probably want different links for different leave types? --> | ||
<a type="action" name="hr_attendance.hr_attendance_action" /> | ||
</xpath> | ||
<xpath expr="//a[@name='hr_attendance.hr_attendance_action']" position="inside"> | ||
<xpath | ||
expr="//t[@t-elif='requires_allocation']/span[@t-esc="timeoff[1]['virtual_remaining_leaves']"]" | ||
position="move" | ||
/> | ||
</xpath> | ||
<xpath | ||
expr="//t[@t-elif='requires_allocation']/a/span[@t-esc="timeoff[1]['virtual_remaining_leaves']"]" | ||
position="attributes" | ||
> | ||
<attribute name="t-esc"> | ||
timeoff[1]['virtual_remaining_leaves_formatted'] | ||
</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//t[@t-else]/span[@t-esc="timeoff[1]['virtual_leaves_taken']"]" | ||
position="attributes" | ||
> | ||
<attribute name="t-esc"> | ||
timeoff[1]['virtual_leaves_taken_formatted'] | ||
</attribute> | ||
</xpath> | ||
</t> | ||
</templates> |