Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5433 Представления

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
4427
4
окт. 24
23203
0
июн. 23
1816
0
июл. 21
2027
2
июл. 17
4510