Skip to Content
Menu
This question has been flagged
1 Reply
6238 Views

By default Odoo is showing always at least 4 rows with the tree view. As described in this topic:
\https://stackoverflow.com/questions/46468472/tree-view-showing-extra-empty-fields

​I would like to decrease this value to one or two rows. But my custom module changes nothing.

I have this js file odoo\addons\custom_theme\static\src\js\views\list\list_renderer.js:

odoo.define('custom_theme.custom_table_rows', function (require){
"use strict";

//require the module to modify:
var ListRenderer = require(website_sale_delivery.ListRenderer);

//override the method:
ListRenderer.include({
_renderBody: function () {
var $rows = this._renderRows();
while ($rows.length < 1) {
$rows.push(this._renderEmptyRow());
}
return $('<tbody>').append($rows);
}
});
});

And I called it inside xml odoo\addons\custom_theme\views\header.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets_backend" name="Custom_header_theme" inherit_id="web.assets_backend">
<xpath expr=".">
    <script type="text/javascript" src="/custom_theme/static/src/js/views/list/list_renderer.js"></script>
</xpath>
</template>
</data>
</odoo>

Also xml file called inside manifest:

'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
'views/templates.xml',
'views/header.xml',
],

And it does nothing. When I instead modify the js file directly inside source code ("odoo/addons/web/static/src/js/views/list/list_renderer.js") it is working and less rows are appearing. Module as a whole is working because it performs other modifications.

What is wrong?

Avatar
Discard
Best Answer

It seems import is wrong

write

var ListRenderer = require('web.ListRenderer');​

instead of 

var ListRenderer = require(website_sale_delivery.ListRenderer);
Avatar
Discard
Author

Ohh, you are right. I changed it but sadly it still does not work.

is there in error in the browser console?

Author

It is

Failed modules:

"custom_theme.custom_table_rows"

error: ReferenceError: "web is not defined"

Related Posts Replies Views Activity
1
May 21
15416
1
Apr 21
3968
1
Apr 20
2718
0
Mar 20
1914
1
Feb 20
3613