mirror of https://github.com/OCA/web.git
[IMP] web_widget_one2many_product_picker: Destroy localData of virtual records
parent
167db197a2
commit
c964295a27
|
@ -81,7 +81,12 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRecord", fu
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
this.$card.off("")
|
this.$el.remove();
|
||||||
|
this.$card.off("");
|
||||||
|
const model = this.options.basicFieldParams.model;
|
||||||
|
if (this.state) {
|
||||||
|
model.removeVirtualRecord(this.state.id);
|
||||||
|
}
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -182,12 +187,15 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRecord", fu
|
||||||
|
|
||||||
this.fields = this.getParent().state.fields;
|
this.fields = this.getParent().state.fields;
|
||||||
this.fieldsInfo = this.getParent().state.fieldsInfo.form;
|
this.fieldsInfo = this.getParent().state.fieldsInfo.form;
|
||||||
|
var model = this.options.basicFieldParams.model;
|
||||||
|
if (this.state) {
|
||||||
|
model.removeVirtualRecord(this.state.id);
|
||||||
|
}
|
||||||
this.state = viewState;
|
this.state = viewState;
|
||||||
|
|
||||||
if (recordSearch) {
|
if (recordSearch) {
|
||||||
this.recordSearch = recordSearch;
|
this.recordSearch = recordSearch;
|
||||||
}
|
}
|
||||||
var model = this.options.basicFieldParams.model;
|
|
||||||
this.is_virtual = this.state && model.isPureVirtual(this.state.id) || false;
|
this.is_virtual = this.state && model.isPureVirtual(this.state.id) || false;
|
||||||
|
|
||||||
// Check if has cached qty
|
// Check if has cached qty
|
||||||
|
|
|
@ -63,15 +63,6 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRenderer",
|
||||||
_.invoke(this.widgets, 'on_detach_callback');
|
_.invoke(this.widgets, 'on_detach_callback');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Object} widget
|
|
||||||
*/
|
|
||||||
removeWidget: function (widget) {
|
|
||||||
var index = this.widgets.indexOf(widget);
|
|
||||||
widget.destroy();
|
|
||||||
delete this.widgets[index];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,6 +51,24 @@ odoo.define("web_widget_one2many_product_picker.BasicModel", function (require)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeVirtualRecord: function (id) {
|
||||||
|
if (!this.isPureVirtual(id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = this.localData[id];
|
||||||
|
const to_remove = [];
|
||||||
|
this._visitChildren(data, (item) => {
|
||||||
|
to_remove.push(item.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
to_remove.reverse();
|
||||||
|
for (let remove_id of to_remove) {
|
||||||
|
this.removeLine(remove_id);
|
||||||
|
delete this.localData[remove_id];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a virtual records without link it
|
* Generates a virtual records without link it
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue