I have created a custom module, in my tree view, I will always have only 1 row data. But in my tree view it shows extra empty rows. how can I remove those unwanted empty rows?
My view code:
<record model="ir.ui.view" id="ctimesheet.list">
<field name="name">ctimesheet list</field>
<field name="model">time.recorder</field>
<field name="arch" type="xml">
<tree string="TIME SHEET" create="false">
<field name="total_time"/>
<field name="month_time"/>
<field name="yesterday_time"/>
<field name="week_time"/>
<field name="notsubmitted_time"/>
<field name="user_id" invisible="1"/>
</tree>
</field>
</record>
just go to path: Odoo 10.0\server\odoo\addons\web\static\src\js\views and edit file list_view.js line 1115 and change
this.pad_table_to(4);
To
this.pad_table_to(1);
updating javascript by editing odoo code is very bad you shoud use include to override the code:
Create a new module and create a javascript file:
/your_addon_name/static/src/js/list_view.js
in you javascript file override the render method like this:
odoo.define('you_module_name.ListView', function (require) {
"use strict";
// First retrieve the veiw from view_registry
ListView = core.view_registry.get('list');
// now use include to override the render method
ListView.include({
render: function () {
// call super method first
this._super();
// then override what you need
// and best thing here is that you can dor this for
// your model only
if (this.model == 'addon_name.model_name'){
this.pad_table_to(1);
}
}
});
}
of curse just writing javascript will not do the trick we should put ower java script file to backends_asset template to be loaded in odoo backend.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend_custom_id" name="list_view assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_addon_name/static/src/js/list_view.js"></script>
</xpath>
</template>
</odoo>
don't forget to put the xml file to odoo manifest hope this helps you and everyone else
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With