Andrius
Andrius

Reputation: 21118

Odoo: javascript. Can't access some view constructs

I don't get whats going on here, but I can't access some of Odoo views. Particulary, I need to access gantt view.

So running this

odoo.define('mymodule.myWidgetName', function (require) {
"use strict";

var core = require('web.core');
var data_manager = require('web.data_manager');

console.log('list ' + core.view_registry.get('list'));
console.log('calendar ' + core.view_registry.get('calendar'));
console.log('diagram ' + core.view_registry.get('diagram'));
console.log('form ' + core.view_registry.get('form'));
console.log('graph ' + core.view_registry.get('graph'));
console.log('grid ' + core.view_registry.get('grid'));
console.log('kanban ' + core.view_registry.get('kanban'));
console.log('gantt ' + core.view_registry.get('gantt'));
console.log('tree' + core.view_registry.get('tree'));
console.log('many2many_kanban ' + core.view_registry.get('many2many_kanban'));
console.log('one2many_kanban '+ core.view_registry.get('one2many_kanban'));
console.log('pivot ' + core.view_registry.get('pivot'));

});

Log output is this:

list function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

web.assets_backend.js:3126 calendar undefined

web.assets_backend.js:3126 diagram undefined

web.assets_backend.js:3126 form function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

web.assets_backend.js:3126 graph function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

web.assets_backend.js:3126 grid function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

web.assets_backend.js:3126 kanban undefined

web.assets_backend.js:3126 gantt undefined

web.assets_backend.js:3126 tree function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

web.assets_backend.js:3126 many2many_kanban undefined

web.assets_backend.js:3126 one2many_kanban undefined

web.assets_backend.js:3126 pivot function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
this._super=null;if(!initializing&&this.init){var ret=this.init.apply(this,arguments);if(ret){return ret;}}
return this;}

AS you can see from log, views like gantt or kanban are undefined. Though if I log console.log(core.view_registry.map)). I can see that every one of them have values of their constructs - I mean it looks like every view is defined..

So core.view.registry.map log outputs this:

As you can see some views are undefined even though I see that they were registered there and should be accessible. if I console.log(core.view_registry.map) It returns this:

calendar: function Class()
diagram: function Class()
form: function Class()
gantt: function Class()
graph: function Class()
grid: function Class()
kanban: function Class()
list: function Class()
many2many_kanban: function Class()
one2many_kanban: function Class()
pivot: function Class()
tree: function Class()

As you can see every key has its construct. So how come some are undefined?..

So what the heck is going on here?? Am I missing some gotcha here?

If dependencies are important in this case, my module is dependent on both web and web_gantt (which defines gantt view, though I guess only web_gantt should be needed as dependency anyway).

Also Looking into how gantt view is defined:

core.view_registry.add('gantt', GanttView);
return GanttView;

It looks like it should be straightforward and I should be able to access GanttView, but for some reason I can't..

Upvotes: 1

Views: 566

Answers (1)

Andrius
Andrius

Reputation: 21118

It is possible to directly access gantt view without going into view_registry using var GanttView = require('web_gantt.GanttView'). Though it still does not make sense to register view into registry if it can't be access from there.

Upvotes: 1

Related Questions