From 86fc6a581a44ad1c110f4fc58e55e8e0b52a87d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 25 Jul 2020 00:49:32 +0200 Subject: [PATCH] Position copied records based on order issue9474 review311851002 --- CHANGELOG | 1 + src/model.js | 8 ++++++-- src/screen.js | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4a657298b2..a92b147caa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Position copied records based on order * Sanitize translated RichtText fields content (issue9453) * Allow configuration of default colors for graph and calendar * Sanitize RichtText fields content (issue9405) diff --git a/src/model.js b/src/model.js index 675ec1f08c..eff0573be2 100644 --- a/src/model.js +++ b/src/model.js @@ -79,7 +79,10 @@ this.__readonly = value; } }); - array.load = function(ids, modified) { + array.load = function(ids, modified, position) { + if ((position === undefined) || (position == -1)) { + position = this.length; + } var new_records = []; var i, len; for (i = 0, len = ids.length; i < len; i++) { @@ -88,7 +91,8 @@ if (!new_record) { new_record = new Sao.Record(this.model, id); new_record.group = this; - this.push(new_record); + this.splice(position, 0, new_record); + position += 1; } new_records.push(new_record); } diff --git a/src/screen.js b/src/screen.js index ee5262e7c5..bb382e29ac 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1591,7 +1591,7 @@ var records = this.current_view.selected_records; this.model.copy(records, this.context) .then(function(new_ids) { - this.group.load(new_ids); + this.group.load(new_ids, false, this.new_position); if (!jQuery.isEmptyObject(new_ids)) { this.current_record = this.group.get(new_ids[0]); }