From 9654f6b8e0313553a555a8c9cb8349ca1c412ca3 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 11 May 2018 15:05:18 +0200 Subject: [FIX] web: o2m editable decorated, paged, ordered supports adds/cancel Have a decorated (conditional on field) editable list, with a default_order. Have more records than the pager allows. Add an item, and hit escape to cancel addition. Before this commit, the cancellation crashed because the first record on the other page was trying to evaluate the decoration for its row, which is wrong in the first place. This was because creating a record increases the limit of the list, to be able to see the record being created. At cancellation though, that limit was never decreased. After this commit, the whole flow happens without problem. OPW 1844495 closes #24682 --- addons/web/static/src/js/views/basic/basic_model.js | 9 +++++++++ 1 file changed, 9 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 ea3b8f17a09..d276e66d33f 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -875,6 +875,15 @@ var BasicModel = AbstractModel.extend({ // x2Many case: the new record has been stored in _changes, as a // command so we remove the command(s) related to that record parent._changes = _.filter(parent._changes, function (change) { + if (change.id === elementID && + change.operation === 'ADD' && // For now, only an ADD command increases limits + parent.tempLimitIncrement) { + // The record will be deleted from the _changes. + // So we won't be passing into the logic of _applyX2ManyOperations anymore + // implying that we have to cancel out the effects of an ADD command here + parent.tempLimitIncrement--; + parent.limit--; + } return change.id !== elementID; }); } else { -- cgit v1.2.3 From 94a7bef5db7e0f131d2cd5208d0ac1f78edce117 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 29 May 2018 10:03:42 +0200 Subject: [FIX] web: domain evaluation in parented m2o in o2m list Model A has a o2m to model B Model B has a m2o parent_id on B In A's form, add a B item, then in the m2o, create record Save and New Click on the m2o Before this commit, the python crashed on name_search. This was because we sent the virtual ids to it After this commit, there is no crash OPW 1850212 closes #24948 --- addons/web/static/src/js/views/basic/basic_model.js | 9 +++++++++ 1 file changed, 9 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 d276e66d33f..042f7bafa97 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3129,6 +3129,15 @@ var BasicModel = AbstractModel.extend({ // when sent to the server, the x2manys values must be a list // of commands in a context, but the list of ids in a domain ids.toJSON = _generateX2ManyCommands.bind(null, fieldName); + } else if (field.type === 'one2many') { // Ids are evaluated as a list of ids + /* Filtering out virtual ids from the ids list + * The server will crash if there are virtual ids in there + * The webClient doesn't do literal id list comparison like ids == list + * Only relevant in o2m: m2m does create actual records in db + */ + ids = _.filter(ids, function (id) { + return typeof id !== 'string'; + }); } context[fieldName] = ids; } -- cgit v1.2.3