Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Time Off
Entity: hr.leave
Compute Method: _compute_duration_display
| Inputs | Method | Outputs |
|---|---|---|
|
for leave in self:
duration = leave.number_of_days
unit = _('days')
display = "%g %s" % (float_round(duration, precision_digits=2), unit)
- if leave.leave_type_request_unit == "hour":
+ if leave.work_entry_type_request_unit == "hour" \
+ or (leave.work_entry_type_request_unit in ('day', 'half_day')
+ and (leave.is_time_rule_trimmed or leave.source_leave_id)
+ and leave.number_of_hours > 0
+ and leave.number_of_days < 1):
+ # hour-type leaves, and sub-day rule-split segments of day/half-day type,
+ # show H:MM hours for clarity instead of a fractional day count
hours, minutes = divmod(abs(leave.number_of_hours) * 60, 60)
minutes = round(minutes)
if minutes == 60:
minutes = 0
hours += 1
duration = '%d:%02d' % (hours, minutes)
unit = _("hours")
display = f"{duration} {unit}"
leave.duration_display = display
|
|
