summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorCedric Snauwaert <csn@openerp.com>2019-06-27 12:17:59 +0000
committerAaron Bohy <aab@odoo.com>2019-07-02 06:14:04 +0000
commitba7675210f1cc71cfe47a062388c39fce8c9cec0 (patch)
treecd74cda5de8f26755847a3c7a90f6b33641e85a6 /addons/web/static/src/js/views/basic
parenta766f5b7c19d6387a946b1556c59219d95767771 (diff)
[FIX] web: two o2m fields with onchanges
Scenario: We have the following models: class A: submodel_1_ids = fields.One2Many(B) submodel_2_ids = fields.One2Many(B) class B: parent_model = fields.many2one(A) name = fields.Char() and the following onchange on class A: api.onchange(submodel_1_ids) def onchange_submodel1(self): // add newline to second o2m submodel_2_ids = submodel_1_ids api.onchange(submodel_2_ids) def onchange_submodel2(self): do_smth In a form view containing both o2m fields (editable="bottom" lists): 1) add a line on first o2m -> the onchange adds the same line on the other o2m 2) add a line on the second o2m Before this rev., the line (added in (2)) wasn't added at the bottom of the list, and the row in edition wasn't the newly created one. The issue occurred because we couldn't retrieve the datapoint corresponding to the other line (the one created by the onchange on the first o2m), and we thus created another which was put at the end of the list. Then, the BasicModel messed up the sort of the records because it couldn't match the virtual id of that new record with the ones in orderedResIds. We fixed the issue by preventing the model from creating a new datapoint after the onchange, by using 'ref' instead of 'res_id' to retrieve the one that already exist. closes odoo/odoo#34493 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com> Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js2
1 files changed, 1 insertions, 1 deletions
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 0cddc887f18..60c2f6a3314 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1597,7 +1597,7 @@ var BasicModel = AbstractModel.extend({
// updating an existing (virtual) record
var previousChange = _.find(oldChanges, function (operation) {
var child = self.localData[operation.id];
- return child && (child.res_id === command[1]);
+ return child && (child.ref === command[1]);
});
recID = previousChange && previousChange.id;
rec = self.localData[recID];