[FIX] web_widget_one2many_product_picker: Duplicated records on mobile

In mobile the deactivation of the buttons is not working properly, so
now we ensure that only the last action is triggered using
debounce.
This commit is contained in:
Alexandre D. Díaz
2021-03-18 15:36:56 +01:00
parent 86feea96e2
commit fc792719a9
2 changed files with 19 additions and 23 deletions

View File

@@ -259,10 +259,11 @@ odoo.define("web_widget_one2many_product_picker.ProductPickerQuickCreateFormView
success_callback: function () {
self.trigger_up("create_quick_record", {
id: record.id,
callback: function () {
self.model.unsetDirty(self.handle);
self._enableQuickCreate();
},
});
self.model.unsetDirty(self.handle);
//self._updateButtons();
self._enableQuickCreate();
},
block: true,
});
@@ -271,8 +272,6 @@ odoo.define("web_widget_one2many_product_picker.ProductPickerQuickCreateFormView
_remove: function () {
if (this._disabled) {
// Don't do anything if we are already creating a record
return $.Deferred();
}
@@ -301,10 +300,11 @@ odoo.define("web_widget_one2many_product_picker.ProductPickerQuickCreateFormView
success_callback: function () {
self.trigger_up("update_quick_record", {
id: record.id,
callback: function () {
self.model.unsetDirty(self.handle);
self._enableQuickCreate();
}
});
self.model.unsetDirty(self.handle);
//self._updateButtons();
self._enableQuickCreate();
},
block: true,
});

View File

@@ -592,22 +592,18 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
{operation: "ADD", id: evt.data.id},
{notifyChange: false}
).then(function () {
if (self.options.auto_save) {
self.parent_controller.saveRecord(undefined, {stayInEdit: true}).then(function (rrr) {
// Because 'create' generates a new state and we can't know these new id we
// need force update the all the current states.
self._setValue(
{operation: "UPDATE", id: evt.data.id},
{doNotSetDirty: true}
).then(function () {
if (evt.data.callback) {
evt.data.callback();
}
});
self.parent_controller.saveRecord(undefined, {stayInEdit: true}).then(function () {
// Because 'create' generates a new state and we can't know these new id we
// need force update all the current states.
self._setValue(
{operation: "UPDATE", id: evt.data.id},
{doNotSetDirty: true}
).then(function () {
if (evt.data.callback) {
evt.data.callback();
}
});
} else if (evt.data.callback) {
evt.data.callback();
}
});
});
} else {
// This is used to know when need use 'yellow' color