32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import models, api, fields
|
|
from odoo.tools.float_utils import float_round
|
|
from odoo.tools.translate import _
|
|
|
|
|
|
class HolidaysAllocation(models.Model):
|
|
_inherit = "hr.leave.allocation"
|
|
|
|
type_request_unit = fields.Selection(
|
|
selection_add=[
|
|
("c_day", "Calendar Days"),
|
|
]
|
|
)
|
|
|
|
@api.depends("number_of_hours_display", "number_of_days_display")
|
|
def _compute_duration_display(self):
|
|
for allocation in self:
|
|
amount = (
|
|
float_round(allocation.number_of_hours_display, precision_digits=2)
|
|
if allocation.type_request_unit == "hour"
|
|
else float_round(allocation.number_of_days_display, precision_digits=2)
|
|
)
|
|
if allocation.type_request_unit == "c_day":
|
|
units = _("calendar day(s)")
|
|
elif allocation.type_request_unit == "hour":
|
|
units = _("hour(s)")
|
|
else:
|
|
units = _("working day(s)")
|
|
allocation.duration_display = "%g %s" % (amount, units)
|