Enable Dark Mode!
how-to-set-up-and-use-system-parameters-in-odoo-16.jpg
By: Prathyunnan R

How to Set Up & Use System Parameters in Odoo 16

Technical Odoo 16

System parameters in Odoo 16 serve as a fundamental tool for storing and managing various configuration settings within your Odoo instance. These settings can significantly impact your business processes and system behavior. In this guide, we'll explore how to create and utilize system parameters in Odoo 16.

Understanding System Parameters in Odoo

In Odoo, system parameters are essentially a model used for storing configuration settings. These parameters play a crucial role in maintaining the functionality and behavior of your Odoo instance. One critical use case is the web.base.url parameter, which Odoo examines every time a user logs in. Suppose the URL used for login does not match the saved web.base.url, Odoo automatically updates it.

Creating System Parameters in Odoo 16

You can create system parameters in Odoo 16 through the user interface or directly within a module.

Creating System Parameters via the User Interface:

To create system parameters via the user interface, follow these steps:

1. Activate Developer Mode:

2. Start by activating Developer Mode in Odoo.

Access System Parameters:

* Navigate to the "Settings" module.

* Under the "Technical" section, locate and click on "System Parameters."

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

3. Create a New System Parameter:

* Click the "Create" button to add a new system parameter.

* Fill in the following fields:

* Key: Assign a unique identifier for the parameter.

* Value: Enter the value associated with the parameter.

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

4. Save Changes:

Remember to click "Save" to confirm the creation of the new system parameter.

Creating System Parameters within a Module:

To create system parameters directly within a module in Odoo 16, you can add a record inside the module's XML file, as shown below:

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

Using System Parameters in Odoo 16

Once you've created system parameters, you can utilize them to customize your Odoo 16 instance in various ways:

1. Localization Settings:

Customize date formats, currency symbols, and time zones to align with your business's geographic location.

2. Email Configuration:

Tailor email templates and server settings to maintain consistent branding and communication.

3. Invoice and Payment Terms:

Streamline invoicing and payment processes by configuring default terms.

4. Security Settings:

Enhance security through password policies, access controls, and session timeouts.

Accessing System Parameters in Python

In Odoo 16, you can interact with system parameters through Python code. By using the get_param method, you can retrieve the values associated with specific keys stored as system parameters. These values are initially stored as strings, but you can easily convert them to other data types to meet your requirements. If a record with the specified key does not exist, the result will be None.

from odoo import api, fields, models
class MyModel(models.Model):
   _name = 'custom_module.my_model'
   _description = 'Description'
   @api.model
   def read_system_parameter(self):
       # Retrieve a system parameter value by its key
       system_parameter_value = self.env['ir.config_parameter'].get_param(
           'system_parameter_key', '')
       # You can convert the value to other data types here if needed
       return system_parameter_value

Modifying System Parameters in Python

In addition to reading system parameters, you can also modify their values from your Odoo module using the set_param method. This is helpful when you need to update system parameters to reflect changes in your Odoo 16 instance.

from odoo import api, fields, models
class MyModel(models.Model):
    _name = 'custom_module.my_model'
    _description = 'Description'
    @api.model
    def update_system_parameter(self):
        custom_value = 10  # Define the new value
        # Use the set_param method to update the system parameter
        self.env['ir.config_parameter'].set_param('system_parameter_key', custom_value)

Dealing with Multiple URLs in Odoo 16

If your Odoo 16 instance can be accessed from different URLs, such as example_url_1.com and example_url_2.com, there's a consideration related to web.base.url. Odoo will update the web.base.url when an admin logs in from a specific URL, potentially causing complications.

To address this:

* Ensure Odoo is accessible only through the desired URL.

* Prevent Odoo from altering the web.base.url by setting "web.base.url.freeze" to "True."

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

In Odoo 16, system parameters offer flexibility and customization to adapt the software to your organization's unique requirements. By following these steps, you can harness the power of system parameters to optimize your Odoo experience.


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



0
Comments



Leave a comment

 


whatsapp
location

Calicut

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

location

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

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