From b8bf945335f2e52dbd07f2560108f2ee4637598d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 19 Apr 2018 14:34:00 +0200 Subject: [FIX] web: do not change pager when discarding changes Here is a scenario that could happen before this commit: 1. go to a list view with more than one record, say 3 2. click on the 3rd record to open the form view 3. the pager says 3/3 4. click on edit button 5. click on discard button 6. the pager says 1/3 (but the record displayed is still the same) It is often necessary to restore the offset for the sub records, because the number of pages in a one2many could have changed. However, it is not a good idea to do that for the main record, since it interferes with the usual flow of operations. --- addons/web/static/src/js/views/basic/basic_model.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 8fdcb305ddc..969e81576b1 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -347,6 +347,7 @@ var BasicModel = AbstractModel.extend({ var element = this.localData[id]; var isNew = this.isNew(id); var rollback = 'rollback' in options ? options.rollback : isNew; + var initialOffset = element.offset; this._visitChildren(element, function (elem) { if (rollback && elem._savePoint) { if (elem._savePoint instanceof Array) { @@ -365,6 +366,7 @@ var BasicModel = AbstractModel.extend({ delete elem.tempLimitIncrement; } }); + element.offset = initialOffset; }, /** * Duplicate a record (by calling the 'copy' route) -- cgit v1.2.3 From 30490cae89a3c528c01f470e828f11853df25126 Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Sun, 15 Apr 2018 07:51:36 -0500 Subject: [FIX] web: handle nested x2m default values The initial rev. odoo/odoo@2d3ecf2 that was supposed to handle this use case was in fact only dealing with one command as default value for nested x2m, not more. The basic model can now handle multiple commands. Closes #24241 --- addons/web/static/src/js/views/basic/basic_model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 969e81576b1..e311378eee4 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3636,7 +3636,7 @@ var BasicModel = AbstractModel.extend({ r._changes[fieldName] = rec.id; many2ones[fieldName] = true; } else if (_.contains(['one2many', 'many2many'], fieldType)) { - var x2mCommands = commands[0][2][fieldName]; + var x2mCommands = value[2][fieldName]; defs.push(self._processX2ManyCommands(r, fieldName, x2mCommands)); } else { r._changes[fieldName] = self._parseServerValue(field, r._changes[fieldName]); -- cgit v1.2.3