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.
We will need to have the Developer Mode activated. If it's not, activate it in the Odoo About dialog.
To modify a language's locale settings, follow these steps:
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.
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.
3.147.81.214