OdooWiki OCA HUB

Date & Time Formatter

datetime_formatter folder_open OCA/server-tools open_in_new
Tools License: AGPL-3

This module was written to extend the functionality of Odoo language engine to support formatting Date, Time and Datetime fields easily and allow you to print them in the best format for the user.

auto_awesome What this module does

AI-generated from the code · Odoo 16.0

Adds helper functions so dates, times and datetimes can be printed in each user's preferred language format. It is a technical tool used by other modules, not a screen users open directly.

This module extends Odoo's language settings (res.lang) with two helper methods that other modules can call when they need to show a date, a time or a full date-and-time in the format the user's language expects.

  • best_match finds the most suitable installed language: it can take a language code such as en_US, otherwise it falls back to the current context language, the user's language, or the first active language in the database. If the requested language is not installed, it either raises an error or safely returns the first installed language, depending on the option chosen.
  • datetime_formatter converts a value into text using that language's date and time format. It accepts a text, a number or a real date-time value. The caller can ask for a date only, a time only, or both joined by a separator. If the language has no format configured, standard server formats are used as a fallback.

There are no new menus, buttons, reports or business rules for end users. The module only touches res.lang and depends on base. Its purpose is to make date and time display consistent and localised wherever other modules choose to use it.

Depends on

base
Models and fields (1)
  • res.lang · extends an existing model

Text generated by AI (DeepSeek) from reading the Odoo 16.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 5 confirmed, 4 with no information of 9 versions.

Sources · Odoo 16.0

Confirmed on 2026-11-03 in branch 16.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 16.0

This module adds a technical programming feature, and it should be used by addon developers, not by end users. This means that you must not expect to see any changes if you are a user and install this, but if you find you have it already installed, it's probably because you have another modules that depend on this one.

If you are a developer, to use this module, you need to:

  • Call anywhere in your code:
formatted_string = self.env["res.lang"].datetime_formatter(datetime_value)
  • If you use Qweb:
<t t-esc="env['res.lang'].datetime_formatter(datetime_value)"/>
  • If you call it from a record that has a lang field:
formatted_string = record.lang.datetime_formatter(record.datetime_field)
  • models.ResLang.datetime_formatter docstring explains its usage.

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.