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.allocation

Compute Method: _compute_description_validity

View 18.0 View 20.0
Inputs Method Outputs
  • date_to
  • name
  • date_from
for allocation in self:
+             allocation_date_from = fields.Datetime.to_datetime(allocation.date_from or fields.Date.context_today(allocation))
+             allocation_date_to = fields.Datetime.to_datetime(allocation.date_to)
+ 
            if allocation.date_to:
-                 name_validity = _(
+                 name_validity = self.env._(
                    "%(allocation_name)s (from %(date_from)s to %(date_to)s)",
                    allocation_name=allocation.name,
-                     date_from=tools.format_date(self.env, allocation.date_from, date_format='MMM dd yyyy'),
-                     date_to=tools.format_date(self.env, allocation.date_to, date_format='MMM dd yyyy'),
+                     date_from=format_date(allocation.env,
+                         fields.Date.context_today(allocation, allocation_date_from),
+                     ),
+                     date_to=format_date(allocation.env,
+                         fields.Date.context_today(allocation, allocation_date_to),
+                     ),
                )
            else:
-                 name_validity = _(
+                 name_validity = self.env._(
                    "%(allocation_name)s (from %(date_from)s to No Limit)",
                    allocation_name=allocation.name,
-                     date_from=tools.format_date(self.env, allocation.date_from, date_format='MMM dd yyyy'),
+                     date_from=format_date(allocation.env,
+                         fields.Date.context_today(allocation, allocation_date_from),
+                     ),
                )
            allocation.name_validity = name_validity
  • name_validity

Back to entity