This question has been flagged
2 Replies
20827 Views

Is there any documentation or guide on how to create settings for custom modules?

I've managed to create a tab in settings for my module but I don't really understand how to save data to config fields. I tried to look how the config is defined in other modules but it's full of undocumented (at least here https://www.odoo.com/documentation/13.0/reference/orm.html) parameters like implied_group or config_parameter.

Avatar
Discard
Best Answer

Hi,

If you need to make changes inside the res.config.settings, lets us explain with an example,

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

account_no = fields.Char(string='account',
config_parameter="module_name.account_no")

then we have to inherit and add it to the view,


<record id="res_config_settings_view_form_inherit" model="ir.ui.view">
<field name="name">res.config.settings.view.form.</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="25" />
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@data-key='account']/div[2]" position="after">
<h2>Test</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box" title="">
<div class="o_setting_right_pane">
<label for="account_no" />
<div class="text-muted">
Account No:
</div>
<div class="content-group">
<div class="mt16">
<field name="account_no"/>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>


Also you can check this video explaining the same in v12: How To Add Settings/Configuration For Module in Odoo


Thanks

Avatar
Discard
Best Answer

Hi Oskar:

There isn't any documentation for this that I am aware of. However, you can take a look at one of the modules, for example CRM, to see how the res config settings have been implemented.

Based on your description, it looks like you have the view part (tab in settings) figured out. If not, you can refer to this

https://github.com/odoo/odoo/blob/13.0/addons/crm/views/res_config_settings_views.xml

The python class to implement the setting fields is here

https://github.com/odoo/odoo/blob/13.0/addons/crm/models/res_config_settings.py

Hope this helps.

Avatar
Discard