Odoo provides an easy way to create settings in which you can modify their values in Settings > General Settings
.
Table of Contents
Create setting model

Firstly, we need to define a model which inherits res_config_settings.
class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' custom_emails = fields.Char('Custom Emails', config_parameter='my_module.custom_emails')
Create a views_res_config_settings.xml
and add it to the manifest.
'data': [ 'views/views_res_config_settings.xml', ],
views_res_config_settings.xml
<?xml version="1.0" encoding="utf-8"?> <odoo> <data> <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" data-key="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_emails"/> <div class="text-muted">These emails are used for sending log</div> <field name="custom_emails" widget="text"/> </div> </div> </div> </div> </xpath> </field> </record> </data> </odoo>
Access field values stored in res.config.settings
As you see in the model’s config_parameter above, the field’s value is stored in my_module.custom_emails
.
custom_emails = self.env['ir.config_parameter'].get_param('my_module.custom_emails') or '[email protected]'