Enable Dark Mode!
how-to-set-up-use-system-parameters-in-odoo-18.jpg
By: Anaswara S Sunil

How to Set Up & Use System Parameters in Odoo 18

Functional Odoo 18 Accounting Invoice

System parameters in Odoo 18 are a powerful mechanism for storing and managing configuration settings that govern your instance’s behavior. These parameters influence everything from user authentication to email servers and localization settings. This guide walks you through how to create and use system parameters in Odoo 18 effectively.

System parameters in Odoo are key-value pairs stored in the ir.config_parameter model. They're essential for maintaining flexible configuration without modifying core code.

One notable example is the web.base.url parameter. Odoo checks this every time a user logs in. If the login URL doesn't match this value, Odoo updates it automatically unless otherwise specified.

Creating System Parameters in Odoo 18

You can create system parameters either through the User Interface (UI) or directly inside a custom module.

Creating via the User Interface

1. Activate Developer Mode

Navigate to Settings > Activate the Developer Mode (or add ?debug=1 to the URL).

2. Access System Parameters

Go to Settings > Technical > Parameters > System Parameters.

How to Set Up & Use System Parameters in Odoo 18-cybrosys

3. Create a New Parameter

* Click NEW.

* Fill in:

i. Key: A unique identifier for your parameter.

ii. Value: The configuration value (stored as a string).

* Click Save.

How to Set Up & Use System Parameters in Odoo 18-cybrosys

Creating via a Module

To include parameters in your module's data, define them in an XML file like this:

<odoo>
<data noupdate="0">
  <record id="auth_password_minlength" model="ir.config_parameter">
  <field name="key">auth_password_minlength</field>
  <field name="value">10</field>
  </record>
</data>
</odoo>

This will create a system parameter named auth_password_minlength with a value of 10.

Using System Parameters in Odoo 18

System Parameters allow for flexible configuration of your Odoo instance without modifying code. Here’s how they’re commonly used:

1. Localization Settings

Define preferences such as date format, currency display, and time zone to match regional standards and user expectations.

2. Email Configuration

Manage mail server settings and standardize email content to ensure consistent and reliable communication.

3. Invoice and Payment Terms

Set default payment conditions and streamline billing operations by automating recurring financial settings.

4. Security Settings

Improve system security by enforcing password policies, setting access restrictions, and controlling session behaviors.

Accessing Parameters in Python Code

Use the get_param method to retrieve a parameter value:

def read_system_parameter(self):
   value = self.env['ir.config_parameter'].get_param(
      'system_parameter_key')
   return value

Note: get_param returns values as strings—you may need to cast them to int, bool, or float.

Modifying Parameters in Python

Update or create a parameter with set_param:

def update_system_parameter(self):
   new_value = 10
   self.env['ir.config_parameter'].set_param('system_parameter_key',
                                   new_value)
   return False

Managing Multiple URLs

If your instance is accessed via multiple domains (e.g., example1.com, example2.com), the web.base.url might auto-update based on the admin login.

To stabilize the URL:

1. Ensure Odoo is accessed from a single canonical domain.

2. Set the following system parameter:

Key: web.base.url.freeze

Value: True

This prevents Odoo from changing web.base.url automatically.

Conclusion

System parameters in Odoo 18 provide a robust way to customize and fine-tune your environment. Whether you're setting default currency symbols, customizing email servers, or enforcing security policies, these parameters give you full control—without touching the source code.

By leveraging both the UI and Python API, you can make your Odoo instance more powerful and tailored to your business.

To read more about An Overview of Field Parameters in Odoo 17, refer to our blog An Overview of Field Parameters in Odoo 17.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message