diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-02-27 16:15:54 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 1a0702f1e20a8347a1135ade60858f5905bbca2d (patch) | |
| tree | 081fdb9f6bcdc8dee0603c06b5e16bd6517055f4 /addons/web/static/src/js/views/basic | |
| parent | 4d12ec87bcb95150e82c519d7c8ac51b75ef9968 (diff) | |
[FIX] web: properly handles dirty data in form views
Before this commit, we only consider the BasicModel point of view to
determine if a record is dirty. It is good when we want to determine if
it is actually necessary to save the data, but not correct when we want
to know if some changes can be discarded.
With this commit, the form controller keeps track of its 'dirty' state,
coming from user interactions. It uses this flag to determine if
changes can be discarded.
Diffstat (limited to 'addons/web/static/src/js/views/basic')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_controller.js | 13 |
1 files changed, 13 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 24b5c7fa3d0..2847003f5df 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -33,6 +33,7 @@ return AbstractController.extend(FieldManagerMixin, { this.hasButtons = params.hasButtons; FieldManagerMixin.init.call(this, this.model); this.handle = params.initialState.id; + this.isDirty = false; }, /** * @override @@ -149,6 +150,18 @@ return AbstractController.extend(FieldManagerMixin, { //-------------------------------------------------------------------------- /** + * We need to keep manually track of the isDirty property. Note that it is + * not the same as the one from the basic model. A new record from the + * basic model is considered dirty, but from the controller point of view, + * there was no user interaction and should not be dirty. + * + * @private + */ + _onFieldChanged: function () { + this.isDirty = true; + FieldManagerMixin._onFieldChanged.apply(this, arguments); + }, + /** * When a reload event triggers up, we need to reload the full view. * For example, after a form view dialog saved some data. * |
