Configure language-related settings

Languages and their variations (such as es_MX for Mexican Spanish) also provide locale settings such as date and number formats.

They come with appropriate defaults, so as long as the user is using the correct language, the locale settings should be the appropriate ones.

But you still might want to modify a language's settings. For example, you might prefer to have the user interface in the default English, but want to change the American default date and number formats to your needs.

Getting ready

We will need to have the Developer Mode activated. If it's not, activate it in the Odoo About dialog.

How to do it...

To modify a language's locale settings, follow these steps:

  1. To check the installed languages and their configurations, select the Settings | Translations | Languages menu option. Clicking on one of the installed languages will open a form with the corresponding settings:
    How to do it...
  2. Edit the language settings. To change the date to the ISO format, change Date Format to %Y-%m-%d, and to change the number format to use a comma as a decimal separator, modify the Decimal Separator and Thousands Separator fields accordingly.

How it works...

When signing in and creating a new Odoo user session, the user language is checked in the user preferences and set in the lang context key. This is then used to format the outputs appropriately: the source texts are translated to the user language, and the dates and numbers are formatted according to the language's current locale settings.

There's more...

Server side processes are able to modify the context in which actions are run. For example, to get a record set where the dates are formatted according to the English format independent of the current user's language preference, you could do the following:

en_records = self.with_context(lang='en_EN').search([])

For more details, refer to Chapter 6, Advanced Server Side Development Techniques recipe Calling a method with a modified context.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.81.214