summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js
index be0b9a00bf3..7639d2dea99 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -404,10 +404,13 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
options = options || {};
return this.canBeDiscarded(recordID)
.then(function (needDiscard) {
- if (options.noAbandon || (options.readonlyIfRealDiscard && !needDiscard)) {
+ if (options.readonlyIfRealDiscard && !needDiscard) {
return;
}
self.model.discardChanges(recordID);
+ if (options.noAbandon) {
+ return;
+ }
if (self.model.canBeAbandoned(recordID)) {
self._abandonRecord(recordID);
return;
@@ -702,21 +705,25 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
* re-render (reload the whole form by default)
* @param {string[]} [ev.data.fieldNames] list of the record's fields to
* reload
+ * @param {Function} [ev.data.onSuccess] callback executed after reload is resolved
+ * @param {Function} [ev.data.onFailure] callback executed when reload is rejected
*/
_onReload: function (ev) {
ev.stopPropagation(); // prevent other controllers from handling this request
var data = ev && ev.data || {};
var handle = data.db_id;
+ var prom;
if (handle) {
// reload the relational field given its db_id
- this.model.reload(handle).then(this._confirmSave.bind(this, handle));
+ prom = this.model.reload(handle).then(this._confirmSave.bind(this, handle));
} else {
// no db_id given, so reload the main record
- this.reload({
+ prom = this.reload({
fieldNames: data.fieldNames,
keepChanges: data.keepChanges || false,
});
}
+ prom.then(ev.data.onSuccess).guardedCatch(ev.data.onFailure);
},
/**
* Resequence records in the given order.
@@ -833,7 +840,8 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
userLanguageValue: ev.target.value || '',
dataPointID: record.id,
isComingFromTranslationAlert: ev.data.isComingFromTranslationAlert,
- isText: record.fields[ev.data.fieldName].type === 'text',
+ isText: result.context.translation_type === 'text',
+ showSrc: result.context.translation_show_src,
});
return this.translationDialog.open();
},