Odoo Help


How to implement view for just one record (used to keep configuration data)?

Maxim Litnitskiy
on 9/26/14, 9:52 AM 859 views

res.config,settings is used for automatic module installing and other difficult thing. 

Its name is misleading because it is not used to keep application configuration. Or I simply did not get it right.

So I implemented the following.

Maxim Litnitskiy
On 9/26/14, 9:53 AM

from openerp import fields, models, api, _

class server_settings(models.Model):
    _name = 'asterisk.server.settings'

    ari_url = fields.Char(required=True, string=_('Server URL'))
    ari_user = fields.Char(required=True, string=_('ARI username'))
    ari_pass = fields.Char(required=True, string=_('ARI password'))
    context_name = fields.Char(required=True, string=_('Dialplan context'))

    _defaults = {
        'ari_url': 'http://localhost:8088',
        'context_name': 'dialer',
        'ari_user': '',
        'ari_pass': '',
    def execute(self):
        print self.ari_url, self.ari_user
    def clear(self):
        self.ari_user = ''
        self.ari_pass = ''



        <record id="view_asterisk_server_settings" model="ir.ui.view">
            <field name="name">Asterisk Server Settings</field>
            <field name="model">asterisk.server.settings</field>
            <field name='type'>form</field>
            <field name="arch" type="xml">
                <form string="Configure Asterisk Server">
                        <button string="Apply" type="object" name="execute" class="oe_highlight"/>
                        <button string="Clear" type="object" name="clear" class="oe_link"/>
                    <separator string="ARI Connection Information"/>
                    <group name="Server">
                        <label for="id" string="Asterisk HTTP server URL"/>
                                <field name="ari_url" class='oe_inline'/>
                                <label for="name" string='Usually http://localhost:8088, see http.conf.'/>
                    <div string='ARI configuration'>
                    <group name="ARI">
                        <label for="id" string="ARI access"/>
                                <field name="ari_user" class='oe_inline'/>
                                <label for="ari_user"/>
                                <field name="ari_pass" class='oe_inline'/>
                                <label for="ari_pass"/>
                   <group name="Dialplan">
                        <label for="id" string="Asterisk Dialplan for Dialer"/>
                                <field name="context_name" class='oe_inline'/>
                                <label for="context_name" string='Dialplan context name, see README for details'/>

        <record id="action_asterisk_server_settings" model="ir.actions.act_window">
            <field name="name">Asterisk Dialer</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">asterisk.server.settings</field>
            <field name="view_id" ref="view_asterisk_server_settings"/>
            <field name='view_type'>form</field>
            <field name="view_mode">form</field>
            <field name="target">inline</field>
            <field name='res_id'>1</field>
        <menuitem id="menu_asterisk_server_settings" parent="base.menu_config"
            sequence="200" action="action_asterisk_server_settings"/>


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

Question tools

1 follower(s)


Asked: 9/26/14, 9:52 AM
Seen: 859 times
Last updated: 3/16/15, 8:10 AM