This question has been flagged
1 Reply
4094 Views

Hi,

I would like to custom List view padding in my custom module, so i proceeded like follows :

my_custom_module.js :

odoo.define('my_custom_module', function(require){
    'use strict';
    var core = require('web.core');
    var List = core.view_registry.get('list');
    var QWeb = core.qweb;
    List.List.include({
        render: function () {
            var self = this;
            this.$current.html(
                QWeb.render('ListView.rows', _.extend({}, this, {
                        render_cell: function () {
                            return self.render_cell.apply(self, arguments); }
                    })));
            this.pad_table_to(1);
        },
    });
});

And in my XML :

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <template id="assets_backend" name="my_custom_module assets" inherit_id="web.assets_backend">
        <xpath expr="." position="inside">
            <script src="/my_custom_module/static/src/js/my_custom_module.js" type="text/javascript" />
        </xpath>
    </template>
</odoo>

But problem is that this applies to all my Odoo modules !

How can i specify that the customization applies only to my my_custom_module ?


Thanks for help :)

Avatar
Discard
Best Answer

Hi,

Check the dataset and change the condition for changes if only the datset.model == 'yourmodel', or you can use any other methods as you like. Just console this operator and check the key and values

eg:

View.include({    init:function(parent,dataset,options){        self=this;
        console.log(options._model,dataset._model['name'],"init");
        this._super.apply(this, arguments);
        if (dataset._model['name'] == 'yourmodel'){}

just an example . Try yours

Avatar
Discard