Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
5428 Переглядів

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 :)

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
трав. 17
4405
4
жовт. 24
23193
0
черв. 23
1815
0
лип. 21
2024
2
лип. 17
4506