[IMP] web_widget_one2many_product_picker: Remove items in main lines

pull/1770/head
Alexandre D. Díaz 2020-12-30 13:46:32 +01:00
parent 8425e043e2
commit 91373cfe87
2 changed files with 10 additions and 2 deletions

View File

@ -38,6 +38,7 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRenderer",
this.options = parent.options; this.options = parent.options;
this.mode = parent.mode; this.mode = parent.mode;
this.search_data = parent._searchRecords; this.search_data = parent._searchRecords;
this.search_group = parent._activeSearchGroup;
this.last_search_data_count = parent._lastSearchRecordsCount; this.last_search_data_count = parent._lastSearchRecordsCount;
}, },
@ -75,9 +76,10 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRenderer",
/** /**
* @param {Object} search_data * @param {Object} search_data
*/ */
updateSearchData: function (search_data, count) { updateSearchData: function (search_data, count, search_group) {
this.search_data = search_data; this.search_data = search_data;
this.last_search_data_count = count; this.last_search_data_count = count;
this.search_group = search_group;
this._loadMoreWorking = false; this._loadMoreWorking = false;
this.$btnLoadMore.attr("disabled", false); this.$btnLoadMore.attr("disabled", false);
}, },
@ -128,6 +130,11 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRenderer",
} }
this.widgets = _.compact(this.widgets); this.widgets = _.compact(this.widgets);
if (this.search_group.name === "main_lines") {
_.invoke(to_destroy, "destroy");
return $.when();
}
// If doesn't exists other records with the same product, we need // If doesn't exists other records with the same product, we need
// create a 'pure virtual' record again. // create a 'pure virtual' record again.
for (var index_destroy in to_destroy) { for (var index_destroy in to_destroy) {

View File

@ -352,7 +352,8 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
if (self.renderer) { if (self.renderer) {
self.renderer.updateSearchData( self.renderer.updateSearchData(
self._searchRecords, self._searchRecords,
self._lastSearchRecordsCount self._lastSearchRecordsCount,
self._activeSearchGroup
); );
} }
d.resolve(results); d.resolve(results);