Odoo Help


This community 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.


How can I add a settings option for my custom module?

Norbert J
on 5/29/14, 9:59 AM 807 views


I am creating my first module and I have one field that I am adding that will be a dropdown selection. Instead of hardcoding the options for that field, I would like to have a settings section so that a user can add which options will be available from that dropdown option, and then the user can select one of those options. Can anyone point me in the right direction as to how to do this? Thanks!


You can create an object where you will keep your settings options

class my_settings(osv.osv):
    _name = "my.settings"
    _description = "Settings"
    _columns = {
        'name': fields.char('Setting name', size=64, required=True),
    _sql_constraints = [
        ('name', 'unique(name)', 'Setting name must be unique')
    _order = 'name asc'

And in the main object of your module, you'll create a many2one connection to your settings table like this

class wtv(osv.osv):
    _name = "wtv"
    _description = "WTV"
    _columns = {
        'name': fields.char('Wtv name', size=64, required=True),
    'settings': fields.many2one('my.settings', 'Settings', help='Select an option from the dropdown'),
    _sql_constraints = [ ('name', 'unique(name)', 'Setting name must be unique')   ]
    _order = 'name asc'

In your main wtv form view, when adding the <field name="settings" /> tag, a dropdown will be displayed with the contents of whatever is stored in the my_settings table.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 5/29/14, 9:59 AM
Seen: 807 times
Last updated: 3/16/15, 8:10 AM