Skip to content

Commit

Permalink
[ADD] #3 show hours with float_time widget, make numbers links
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Aug 2, 2023
1 parent a43feaf commit 1662f80
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
9 changes: 8 additions & 1 deletion verdigado_attendance/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"author": "verdigado eG",
"license": "AGPL-3",
"installable": True,
"depends": ["hr_attendance", "hr_attendance_report_theoretical_time"],
"depends": [
"hr_attendance",
"hr_holidays_attendance",
"hr_attendance_report_theoretical_time",
],
"data": [
"data/res.lang.csv",
"security/ir.model.access.csv",
Expand All @@ -22,5 +26,8 @@
"web.assets_backend": [
"verdigado_attendance/static/src/scss/backend.scss",
],
"web.assets_qweb": [
"verdigado_attendance/static/src/xml/hr_holidays.xml",
],
},
}
1 change: 1 addition & 0 deletions verdigado_attendance/models/__init__.py
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
22 changes: 22 additions & 0 deletions verdigado_attendance/models/hr_leave_type.py
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
42 changes: 42 additions & 0 deletions verdigado_attendance/static/src/xml/hr_holidays.xml
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=&quot;timeoff[1]['virtual_remaining_leaves']&quot;]"
position="attributes"
>
<attribute name="t-esc">
timeoff[1]['virtual_remaining_leaves_formatted']
</attribute>
</xpath>
<xpath
expr="//t[@t-elif='requires_allocation']/span[@t-esc=&quot;timeoff[1]['virtual_remaining_leaves']&quot;]"
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=&quot;timeoff[1]['virtual_remaining_leaves']&quot;]"
position="move"
/>
</xpath>
<xpath
expr="//t[@t-elif='requires_allocation']/a/span[@t-esc=&quot;timeoff[1]['virtual_remaining_leaves']&quot;]"
position="attributes"
>
<attribute name="t-esc">
timeoff[1]['virtual_remaining_leaves_formatted']
</attribute>
</xpath>
<xpath
expr="//t[@t-else]/span[@t-esc=&quot;timeoff[1]['virtual_leaves_taken']&quot;]"
position="attributes"
>
<attribute name="t-esc">
timeoff[1]['virtual_leaves_taken_formatted']
</attribute>
</xpath>
</t>
</templates>

0 comments on commit 1662f80

Please sign in to comment.