Skip to content

Commit

Permalink
[ADD] verdigado#95 show which holiday time came from overlaps
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Jan 29, 2024
1 parent 5c28cb9 commit b9358d5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions verdigado_attendance/models/hr_leave_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ def _get_days_request(self):
result[1]["virtual_remaining_leaves_formatted"] = result[1][
"virtual_usable_leaves_formatted"
]
overlap_ids = []
overlap_time = 0.0
for overlap1, overlap2, time in self._get_overlap(
self._get_contextual_employee_id()
):
overlap_ids += overlap1.ids + overlap2.ids
overlap_time += time
result[1]["overlap"] = {
"time": overlap_time,
"ids": overlap_ids,
}
return result

@api.model
Expand Down
19 changes: 19 additions & 0 deletions verdigado_attendance/static/src/js/time_off_calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ odoo.define("verdigado_attendance.time_off_calendar", function (require) {
});
},
});
var Controller = viewRegistry.get("time_off_calendar_all").prototype.config
.Controller;
Controller.include({
events: _.extend({}, Controller.prototype.events, {
"click .overlap": "_onOverlap",
}),
_onOverlap: function (e) {
return this.do_action({
type: "ir.actions.act_window",
res_model: "hr.leave",
views: [
[false, "list"],
[false, "form"],
],
target: "current",
domain: [["id", "in", jQuery(e.currentTarget).data("ids")]],
});
},
});
});
51 changes: 51 additions & 0 deletions verdigado_attendance/static/src/xml/hr_holidays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,56 @@
position="move"
/>
</xpath>
<xpath expr="(//div[hasclass('mt-1')]/t)[1]" position="inside">
<span t-if="timeoff[1]['overlap']['time'] > 0">
<br />
(incl.
<t t-out="timeoff[1]['overlap']['time']" />
from
<!-- prettier-ignore-start -->
<a
href="#"
class="overlap"
t-att-data-ids="JSON.stringify(timeoff[1]['overlap']['ids'])"
>
overlaps
</a>)
<!-- prettier-ignore-end -->
</span>
</xpath>
<xpath expr="(//div[hasclass('mt-1')]/t)[2]" position="inside">
<span t-if="timeoff[1]['overlap']['time'] > 0">
<br />
(incl.
<t t-out="timeoff[1]['overlap']['time']" />
from
<!-- prettier-ignore-start -->
<a
href="#"
class="overlap"
t-att-data-ids="JSON.stringify(timeoff[1]['overlap']['ids'])"
>
overlaps
</a>)
<!-- prettier-ignore-end -->
</span>
</xpath>
<xpath expr="(//div[hasclass('mt-1')]/t)[3]" position="inside">
<span t-if="timeoff[1]['overlap']['time'] > 0">
<br />
(incl.
<t t-out="timeoff[1]['overlap']['time']" />
from
<!-- prettier-ignore-start -->
<a
href="#"
class="overlap"
t-att-data-ids="JSON.stringify(timeoff[1]['overlap']['ids'])"
>
overlaps
</a>)
<!-- prettier-ignore-end -->
</span>
</xpath>
</t>
</templates>

0 comments on commit b9358d5

Please sign in to comment.