Odoo UI widget - how to get settings from database?

Viewed 870

I'm writing an Odoo v9 widget, which renders a URL, based on concatenation of a setting in the database, and the actual form fields.

The setting in the database I figure should live in ir_config_parameter. I'm inserting a default value with my module.

What's the best way to get this value when rendering the widget? Doing an async ajax call using

new Model("ir.config_parameter")

seems a little heavy handed. Is there a better way to be doing this?

Thanks.

Widget code:

    var UrlWidget2 = form_common.FormWidget.extend({
        start: function() {
            this._super();
            this.field_manager.on("field_changed:ref", this, this.display_result);
            this.display_result();
        },
        display_result: function() {
            var ref = this.field_manager.get_field_value("ref");

            if (!ref) return;

            var baseUrl = 'https://example.com'; //this is the value I want to get from the setting in the database. 
            var url = baseUrl + '/foo/' + ref;    

            this.$el.html('<a href="' + url + '" target="portal">View Externally</a><br /><br/>');
        }
    });
1 Answers
Related