Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to dont lost selected items in view (web addon)

By
Cristian Salamea
on 3/1/13, 2:22 AM 1,156 views

Hello, in many2many widget sometimes when you has more than 80 records, you select any records in first page and search more records, but the selected items are lost, i am working to dont lost this.

I found where code does this, hack some JS function but still dont know where runs add rows to widget.

My code[1] is running ok to dont lost selected items in SelectCreateListView.

Waiting for your help to pass selected_items and add to records.

Regards,

openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
init: function (parent, dataset, view_id, options) {
    this.selected_items = [];
    this._super(parent, dataset, view_id, options);
},    
select_record: function(index) {
    console.log('selecciono items '+index);
    this.popup.on_select_elements([this.dataset.ids[index]]);
    this.popup.stop();
},
do_select: function(ids, records) {
    this._super(ids, records);
    this.selected_items.push(ids[0]);
    console.log('selected '+ids);
    console.log('selected_items: '+this.selected_items);
    this.popup.on_click_element(ids);
}

}); }

3
Cristian Salamea
On 3/1/13, 4:25 AM

By now is working with this code:

openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
init: function (parent, dataset, view_id, options) {
    this.selected_items = [];
    this._super(parent, dataset, view_id, options);
},
do_select: function(ids, records) {
    this._super(ids, records);
    if (ids.length > 0){
        dlist = this.selected_items.concat(ids);
        this.selected_items = dlist.filter(function(elem, pos) {
            return dlist.indexOf(elem) == pos;
        });
    }
    this.popup.on_click_element(this.selected_items);
}

});

So i have an issue with unselected items in tree, i was checking the code and has not do_unselected, waiting for your feedback to unselect !

Regards,

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/1/13, 2:22 AM
Seen: 1156 times
Last updated: 8/12/16, 11:12 AM