Odoo Help

6 Answers

Grover Hernando Menacho Quisbert

--Grover Hernando Menacho Quisbert--
WebVision Enterprise Systems
| 6 8 8
La Paz, Bolivia
--Grover Hernando Menacho Quisbert--

Odoo Developer

Grover Hernando Menacho Quisbert
9/5/13, 12:23 AM

To add a configuration page you have to do this:

from openerp.osv import fields, osv 

class custom_config_settings(osv.osv_memory):

    _name = 'custom.config.settings'
    _inherit = 'res.config.settings'
    _columns = {
        'username': fields.char('Username', size=48),
    _defaults = {
        'username': ""

    def get_default_username(self, cr, uid, fields, context=None):
        #some code... 
        #you can get the field content from some table and return it
        #as a example
        user_name=self.pool.get('res.users').browse(cr, uid, uid, context=context).name
        return {'username': user_name}

    def set_default_username(self, cr, uid, ids, context=None):
        #some code... 
        #you can get the field content from some table and return it
        #as a example
        config = self.browse(cr, uid, ids[0], context)
        self.pool.get('res.users').write(cr, uid, uid, {'name': new_username})

And the view:

<?xml version="1.0" encoding="utf-8"?>
    <record id="view_custom_config_settings" model="ir.ui.view">
        <field name="name">custom settings</field>
        <field name="model">custom.config.settings</field>
        <field name="arch" type="xml">
            <form string="Configure Accounting" version="7.0" class="oe_form_configuration">
                    <button string="Apply" type="object" name="execute" class="oe_highlight"/>
                    <button string="Cancel" type="object" name="cancel" class="oe_link"/>
                <field name="username"/>

    <record id="action_custom_config" model="ir.actions.act_window">
        <field name="name">Custom Settings</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">custom.config.settings</field>
        <field name="view_mode">form</field>
        <field name="target">inline</field>

    <menuitem id="menu_custom_config" name="Custom Settings" parent="base.menu_config"
        sequence="16" action="action_custom_config"/>


This is only an example.

The config page works because when you open the configuration page all the "get_" functions will be called. And when you save it all the "set_" functions are going to run.

I hope this can help you.


Taken from OpenERP docs:

Base configuration wizard for application settings. It provides support for setting default values, assigning groups to employee users, and installing modules. To make such a 'settings' wizard, define a model like::

        class my_config_wizard(osv.osv_memory):
            _name = 'my.settings'
            _inherit = 'res.config.settings'
            _columns = {
                'default_foo': fields.type(..., default_model='my.model'),
                'group_bar': fields.boolean(..., group='base.group_user', implied_group='my.group'),
                'module_baz': fields.boolean(...),
                'other_field': fields.type(...),

The method execute provides some support based on a naming convention:

*   For a field like 'default_XXX', ``execute`` sets the (global) default value of
    the field 'XXX' in the model named by ``default_model`` to the field's value.

*   For a boolean field like 'group_XXX', ``execute`` adds/removes 'implied_group'
    to/from the implied groups of 'group', depending on the field's value.
    By default 'group' is the group Employee.  Groups are given by their xml id.

*   For a boolean field like 'module_XXX', ``execute`` triggers the immediate
    installation of the module named 'XXX' if the field has value ``True``.

*   For the other fields, the method ``execute`` invokes all methods with a name
    that starts with 'set_'; such methods can be defined to implement the effect
    of those fields.

The method ``default_get`` retrieves values that reflect the current status of the
fields like 'default_XXX', 'group_XXX' and 'module_XXX'.  It also invokes all methods
with a name that starts with 'get_default_'; such methods can be defined to provide
current values for other fields.
Atchuthan - Technical Consultant, Sodexis Inc
12/13/13, 1:07 PM

@Grover, in many configuration settings available in OpenERP, most of the field does not have get or set function with it

For instance take sales configuration, `module_sale_analytic_plans,

GH Mediacloud, Grover Hernando Menacho Quisbert
12/13/13, 4:20 PM

Of course, but it depends on what you are trying to do: If field name starts with module_ that means that it's going to install that module. It's not an ordinary boolean. I've edited the answer. Hope it helps

Atchuthan - Technical Consultant, Sodexis Inc
12/18/13, 9:53 AM

@thanks Grover, your description was helpful

Iwan Dermawan
11/21/16, 11:42 PM

Please help,

why in my configurations, new record added after Apply button clicked not updated last config data (reload record succesfull display in form)


Thierry Godin

--Thierry Godin--
| 8 7 8
Collegien, France
--Thierry Godin--


Thierry Godin
9/4/13, 6:30 PM


Your configuration will be saved while you're making backup of your database.


Ask a Question
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now