Community mailing list archives

Re: Odoo 9 Javascript API

Phillip Stack, Phillip
- 03/05/2016 16:40:39
The v8 documentation uses this syntax

openerp.oepetstore = function(instance, local) {

    local.HomePage = instance.Widget.extend({
        start: function() {
            var products = new local.ProductsWidget(
                this, ["cpu", "mouse", "keyboard", "graphic card", "screen"], "#00FF00");
        'petstore.homepage', 'instance.oepetstore.HomePage');

However my understanding is that this is no longer the way to do things.  The new api is more along the lines of....

odoo.define('addon_name.jsmodule', function(require) {
"use strict";

var utils = require('web.utils');
var Model = require('web.Model');
var core = require('web.core');
var Widget = require('web.Widget');
var form_common = require('web.form_common');

var JSWidgetClassName = form_common.FormWidget.extend({
    init: function(){
        this._super.apply(this, arguments);

core.form_custom_registry.add('jswidgetname', JSWidgetClassName);