Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4123 Widoki

I am trying to move the position of the "Add an item" button from the bottom of the list to the top(List in Form view).  When you have multiple records in a list, it does not make sense for the user to have to scroll all the way to the bottom of the list to add items.

The function to change it is in the 'web.form_relational' widget and is the 'pad_table_to:' function.

I can change it in the core code by prepending the button instead of appending.

However I can't seem to override the function(which I have done many times already with other mods).

I have the correct dependencies and inclusion of the js file into web.assets_backend. the issue is something in the js code.

MY_CODE

odoo.define('my.form_widgets'), function (require) {

"use strict";

var core = require('web.core');

var form_common = require('web.form_common');

var Model = require('web.DataModel');

var X2ManyList = require('web.form_relational');

var _t = core._t;

console.log("IT WORKS TO HERE"); // This works then get error after

X2ManyList.include({

    pad_table_to: function() {

        console.log('This is where I want to be');

    }

});

});


The error is - error: Some modules could not be started


Could it be because the variable X2ManyList is not registered or returned?


Any help is greatly appreciated!

Thanks

Awatar
Odrzuć
Najlepsza odpowiedź

Your syntax is incorrect, remove the paranthesis from the last line..


UPDATE: 

OK, I have recently come across the issue, I'm not 100% sure but the following may be of at least some help to you.

Try to override the widget like this:

var One2ManyListView = X2ManyListView.extend({
    pad_table_to: function() {
        console.log('This is where I want to be');
    },
});  

After that remember to add your overridden widget to the registry:

core.one2many_view_registry
     .add('list', One2ManyListView);


Thanks

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Thanks thompsonn,

The parenthesis that needs to be removed is after the name in the define statement. (A copy mistake)

That doesn't solve the issue though.

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 23
2762
Override JS mail Rozwiązane
3
lip 21
5060
1
sie 19
2895
1
maj 25
7957
1
lis 21
3345