summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-07-27 13:43:32 +0200
committerAaron Bohy <aab@odoo.com>2017-07-27 14:35:17 +0200
commitc3691a79cb878d4f00617e43e76ad77f1b6076f2 (patch)
tree36ae233788b3d76d590cc5068de6232761cc214f /addons/web/static/src/js
parente989d6333c515d55d0552cc62357aeedd157dce7 (diff)
[FIX] web: grouped list: update row after edition
Grouped lists aren't editable. However, they may contain a widget allowing the edition in readonly (e.g. priority, toggle_button...). This is for example the case in Leaves > Reporting > Leave Details. When the toggle button is clicked, the model is correctly notified of the change, which is correctly sent to the server. However, before this rev., the edited row wasn't redrawn in the grouped list, so the former value of the boolean was still displayed.
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/list/list_editable_renderer.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js
index 08b9e7f1602..3cd93bb6e8b 100644
--- a/addons/web/static/src/js/views/list/list_editable_renderer.js
+++ b/addons/web/static/src/js/views/list/list_editable_renderer.js
@@ -13,6 +13,7 @@ odoo.define('web.EditableListRenderer', function (require) {
*/
var core = require('web.core');
var ListRenderer = require('web.ListRenderer');
+var utils = require('web.utils');
var _t = core._t;
@@ -153,12 +154,32 @@ ListRenderer.include({
*/
setRowMode: function (recordID, mode) {
var self = this;
- var rowIndex = _.findIndex(this.state.data, {id: recordID});
+
+ // find the record and its row index (handles ungrouped and grouped cases
+ // as even if the grouped list doesn't support edition, it may contain
+ // a widget allowing the edition in readonly (e.g. priority), so it
+ // should be able to update a record as well)
+ var record;
+ var rowIndex;
+ if (this.state.groupedBy.length) {
+ rowIndex = -1;
+ var count = 0;
+ utils.traverse_records(this.state, function (r) {
+ if (r.id === recordID) {
+ record = r;
+ rowIndex = count;
+ }
+ count++;
+ });
+ } else {
+ rowIndex = _.findIndex(this.state.data, {id: recordID});
+ record = this.state.data[rowIndex];
+ }
+
if (rowIndex < 0) {
return $.when();
}
var editMode = (mode === 'edit');
- var record = this.state.data[rowIndex];
this.currentRow = editMode ? rowIndex : null;
var $row = this.$('.o_data_row:nth(' + rowIndex + ')');