Skip to content

Instantly share code, notes, and snippets.

@jbarreraballestas
Last active October 9, 2023 15:44
Show Gist options
  • Save jbarreraballestas/378c0a7c68ebbe4f21c37b0e0f3d351a to your computer and use it in GitHub Desktop.
Save jbarreraballestas/378c0a7c68ebbe4f21c37b0e0f3d351a to your computer and use it in GitHub Desktop.
Odoo 16.0 res.config.settings sample

models/res_config_settings.py

from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    sample = fields.Char(string='Sample', config_parameter='module_name.sample')

views/res_config_settings.xml

<odoo>
    <data>
        <record id="res_config_settings_view_form" model="ir.ui.view">
            <field name="name">res.config.settings.module_name</field>
            <field name="model">res.config.settings</field>
            <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="Module Name"
                        string="Module Name" data-key="module_name">
                        <div id="module_name">
                            <h2>Module Name Sample Settings</h2>
                            <div class="row o_settings_container">
                                <div class="col-12 col-lg-12 o_setting_box">
                                    <div class="o_setting_right_pane">
                                        <label for="sample" string="Sample Setting"
                                            class="o_light_label me-4" />
                                        <field name="sample" class="oe_inline" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment