Skip to Content
Menu
This question has been flagged
3 Replies
8229 Views

Here i  am upgrading my app v10  to v11

Trying to add colors to list view using get_listview_color() function call in below code.

 But Js code not executed till end. 

And getting below error in browser console.

error: Some modules could not be started

Failed modules: ["ktree_listview_bgcolor.ListView"]

if any one have solution please response...

JS file code.

odoo.define('ktree_listview_bgcolor.ListView', function (require) {

"use strict";

console.log("dfgfgf");

console.log(5 + 6);

var ListView = require('web.ListView');

var Model = require('web.rpc');

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

var Class = core.Class;

var _t = core._t;

var _lt = core._lt;

var QWeb = core.qweb;

alert("Hello! I am an alert box!!");    (Up to here executing )

var ListView1 = ListView.List.include({   (code not executed under this line, if used ListView.include also)

render: function () {

alert("Hello! second I am an alert box!!");

var self = this;

this.$current.html(

QWeb.render('ListView.rows', _.extend({}, this, {

render_cell: function () {

return self.render_cell.apply(self, arguments); }

})));

var list_bg1 = new Model('list.view.theme');

var test = list_bg1.call('get_listview_color',[this.dataset.model]).then(function(result){

self.$current.children('.table-striped > tbody > tr:nth-of-type(odd)').css({'background-color':result['oddrow']});

self.$current.children('.table-striped > tbody > tr:nth-of-type(even)').css({'background-color':result['evenrow']});

});

this.pad_table_to(4);

}

});

 

});

Avatar
Discard

This is because of the whole JS framework rewrite. Sadly there is no official documentation of it yet (work in progress).

Best Answer

Hi,

You can refer this video from the Odoo experience  about the changes and updates in JS.

The Odoo JS Framework

A Single Page App Using the Odoo JS Framework

Hope it will give you some idea.

Thanks

Avatar
Discard
Author Best Answer

Thanks for useful  info... Niyas Raphy.

Here partial execution...

    I have modified function call code and now function is calling and getting return value in 'result ' variable. But i want to add return values to html table as css. 


Please find my modified code below:


odoo.define('ktree_listview_bgcolor.ListView', function (require) {

"use strict";

var ListView = require('web.ListView');

var rpc = require('web.rpc');

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

var session = require('web.session');

var Class = core.Class;

var _t = core._t;

var _lt = core._lt;

var QWeb = core.qweb;

alert("Hello! I am an alert box!!");

var ListView1 = ListView.include({

init: function () {

alert("Hello! second I am an alert box!!");

var self = this;

var tmp = this._super.apply(this, arguments);

console.log(this.controllerParams.modelName);

/* this.$current.html(

QWeb.render('ListView.rows', _.extend({}, this, {

render_cell: function () {

return self.render_cell.apply(self, arguments); }

})));*/

rpc.query({

model: 'list.view.theme',

method: 'get_listview_color',

args: [self.controllerParams.modelName],

}).then(function (result) {

console.log(result); (Getting return value from py file function)

self.$current.children('.table-striped > tbody > tr:nth-of-type(odd)').css({'background-color':result['oddrow']});

self.$current.children('.table-striped > tbody > tr:nth-of-type(even)').css({'background-color':result['evenrow']});

            (Above two lines are adding background color to html table rows. How can i add css to table.

if am use above code getting 'Uncaught TypeError: Cannot read property 'children' of undefined')

});

console.log("after function ");

//this.pad_table_to(4);

},

});

});

Avatar
Discard