Create, Store, and Get Setting in res.config.settings in Odoo

There are many methods to store and retrieve data in Odoo. The most common is to use the ORM (Object Relational Mapping) system. However, sometimes you need to access data that is in a special model. In these cases, you can use res.config.settings.

Odoo makes it simple to create system’s settings. These settings can be found in Settings > General Settings.


class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    custom_field = fields.Char('Custom Field', config_parameter='my_module.custom_field')    

Create an xml file for UI as views_res_config_settings.xml (remember to include this file in the manifest file):

<?xml version="1.0" encoding="utf-8"?>
        <record id="res_config_settings_view_form" model="ir.ui.view">
            <field name="name">res.config.settings.view.form.inherit</field>
            <field name="model">res.config.settings</field>
            <field name="priority" eval="99"/>
            <field name="inherit_id" ref="base.res_config_settings_view_form"/>
            <field name="arch" type="xml">
                <xpath expr="//div[hasclass('settings')]" position="inside">
                    <div class="app_settings_block" data-string="My Module" string="My Module"
                        <h2>My Module Settings</h2>

                        <div class="row mt16 o_settings_container">

                            <div class="col-12 col-lg-6 o_setting_box">
                                <div class="o_setting_left_pane"/>
                                <div class="o_setting_right_pane">
                                    <label string="Email From" for="custom_field"/>
                                    <div class="text-muted">Store custom data</div>
                                    <field name="custom_emails" widget="text"/>



By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.