diff options
| author | Christophe Matthieu <chm@odoo.com> | 2017-10-24 17:26:48 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2017-10-24 17:26:48 +0200 |
| commit | 9d7f9cc38c00efa4e75c9c1efeb5a1a7d4262550 (patch) | |
| tree | f3d7291b7fca509b9fc17c38235941731f5f4dda /addons/web/static/src/js | |
| parent | 616eedb7e47cc557afbe8bda20cbb490665e4b50 (diff) | |
[FIX] calendar: don't display the created or updated record
If the user change a filtered field, the record is not always displayed.
Wrong domain construction. The automatic filter must be use to filter and
remove items from the view for the unselected and not display the selected.
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/calendar/calendar_controller.js | 6 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/calendar/calendar_model.js | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_controller.js b/addons/web/static/src/js/views/calendar/calendar_controller.js index 11390793c68..d46cb1c5241 100644 --- a/addons/web/static/src/js/views/calendar/calendar_controller.js +++ b/addons/web/static/src/js/views/calendar/calendar_controller.js @@ -54,7 +54,6 @@ var CalendarController = AbstractController.extend({ // Public //-------------------------------------------------------------------------- - /** * Render the buttons according to the CalendarView.buttons template and * add listeners on it. Set this.$buttons with the produced jQuery element @@ -154,10 +153,10 @@ var CalendarController = AbstractController.extend({ _onQuickCreate: function (event) { var self = this; this.model.createRecord(event) - .then(function (id) { + .then(function () { self.quick.destroy(); self.quick = null; - self.reload(id); + self.reload(); }, function (error, errorEvent) { // This will occurs if there are some more fields required // Preventdefaulting the error event will prevent the traceback window @@ -205,7 +204,6 @@ var CalendarController = AbstractController.extend({ if(!options.disableQuickCreate && !event.data.disableQuickCreate && this.quickAddPop) { this.quick = new QuickCreate(this, true, options, data, event.data); - this.quick.on('added', this, this.reload.bind(this)); this.quick.open(); this.quick.focus(); return; diff --git a/addons/web/static/src/js/views/calendar/calendar_model.js b/addons/web/static/src/js/views/calendar/calendar_model.js index 4374421d7b3..b32374057bb 100644 --- a/addons/web/static/src/js/views/calendar/calendar_model.js +++ b/addons/web/static/src/js/views/calendar/calendar_model.js @@ -322,6 +322,7 @@ return AbstractModel.extend({ // List authorized values for every field // fields with an active 'all' filter are skipped var authorizedValues = {}; + var avoidValues = {}; _.each(this.data.filters, function (filter) { // Skip 'all' filters because they do not affect the domain @@ -329,11 +330,20 @@ return AbstractModel.extend({ // Loop over subfilters to complete authorizedValues _.each(filter.filters, function (f) { - if (!authorizedValues[filter.fieldName]) - authorizedValues[filter.fieldName] = []; + if (filter.write_model) { + if (!authorizedValues[filter.fieldName]) + authorizedValues[filter.fieldName] = []; + + if (f.active) { + authorizedValues[filter.fieldName].push(f.value); + } + } else { + if (!avoidValues[filter.fieldName]) + avoidValues[filter.fieldName] = []; - if (f.active) { - authorizedValues[filter.fieldName].push(f.value); + if (!f.active) { + avoidValues[filter.fieldName].push(f.value); + } } }); }); @@ -343,6 +353,9 @@ return AbstractModel.extend({ for (var field in authorizedValues) { domain.push([field, 'in', authorizedValues[field]]); } + for (var field in avoidValues) { + domain.push([field, 'not in', avoidValues[field]]); + } return domain; }, |
