From 2f956d629307dab636dc17afeddf89ea9e5e85a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 21 Apr 2021 23:51:15 +0200 Subject: [PATCH] Fall-back to default order to define new position When there is no order on the screen, we must use the default order because it contains the order of the relation field. issue10298 review340621002 --- src/screen.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/screen.js b/src/screen.js index 31e16d2b20..5b870001f2 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1495,10 +1495,16 @@ }.bind(this)); }, get new_position() { - if (this.order) { - for (var j = 0; j < this.order.length; j++) { - var oexpr = this.order[j][0], - otype = this.order[j][1]; + var order; + if (this.order !== null) { + order = this.order; + } else { + order = this.default_order; + } + if (order) { + for (var j = 0; j < order.length; j++) { + var oexpr = order[j][0], + otype = order[j][1]; if ((oexpr == 'id') && otype) { if (otype.startsWith('DESC')) { return 0;