Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
29029 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
led 23
1305
4
kvě 21
28968
2
lis 23
8957
0
čvc 20
3071
1
čvn 23
2495