summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js9
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js11
2 files changed, 20 insertions, 0 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 67de3ec8ad9..dfbaeb3bd32 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -19,6 +19,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
custom_events: _.extend({}, AbstractController.prototype.custom_events, FieldManagerMixin.custom_events, {
discard_changes: '_onDiscardChanges',
reload: '_onReload',
+ set_dirty: '_onSetDirty',
sidebar_data_asked: '_onSidebarDataAsked',
translate: '_onTranslate',
}),
@@ -554,6 +555,14 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
}
},
/**
+ * @private
+ * @param {OdooEvent} ev
+ */
+ _onSetDirty: function (ev) {
+ ev.stopPropagation(); // prevent other controllers from handling this request
+ this.model.setDirty(ev.data.dataPointID);
+ },
+ /**
* Handler used to get all the data necessary when a custom action is
* performed through the sidebar.
*
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index 8291e798904..377ae7157d3 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -948,6 +948,17 @@ var BasicModel = AbstractModel.extend({
record.fieldsInfo = _.defaults(record.fieldsInfo, viewInfo.fieldsInfo);
},
/**
+ * Manually sets a resource as dirty. This is used to notify that a field
+ * has been modified, but with an invalid value. In that case, the value is
+ * not sent to the basic model, but the record should still be flagged as
+ * dirty so that it isn't discarded without any warning.
+ *
+ * @param {string} id a resource id
+ */
+ setDirty: function (id) {
+ this.localData[id]._isDirty = true;
+ },
+ /**
* For list resources, this changes the orderedBy key.
*
* @param {string} list_id id for the list resource