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

[ADD] #95 show which holiday time came from overlaps #105

Merged
merged 1 commit into from
Feb 5, 2024
Merged
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
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 @@
result[1]["virtual_remaining_leaves_formatted"] = result[1][
"virtual_usable_leaves_formatted"
]
overlap_ids = []
overlap_time = 0.0

Check warning on line 38 in verdigado_attendance/models/hr_leave_type.py

View check run for this annotation

Codecov / codecov/patch

verdigado_attendance/models/hr_leave_type.py#L37-L38

Added lines #L37 - L38 were not covered by tests
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"] = {

Check warning on line 44 in verdigado_attendance/models/hr_leave_type.py

View check run for this annotation

Codecov / codecov/patch

verdigado_attendance/models/hr_leave_type.py#L42-L44

Added lines #L42 - L44 were not covered by tests
"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>
Loading