From 59027c2698bf629b047dfa8492ccba18dbcd1e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 28 Oct 2020 00:02:52 +0100 Subject: [PATCH] Do not rely on current record from screen If the current record is removed, the attribute is set to None by cancel_current. issue9298 review314651002 --- src/window.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/window.js b/src/window.js index a5bebaecfa..7eca19d794 100644 --- a/src/window.js +++ b/src/window.js @@ -455,16 +455,17 @@ !readonly && this.screen.current_record) { result = false; - var added = this.screen.current_record._changed.id; - if ((this.screen.current_record.id < 0) || this.save_current) { + var record = this.screen.current_record; + var added = record._changed.id; + if ((record.id < 0) || this.save_current) { cancel_prm = this.screen.cancel_current( this._initial_value); - } else if (this.screen.current_record.has_changed()) { - this.screen.current_record.cancel(); - cancel_prm = this.screen.current_record.reload(); + } else if (record.has_changed()) { + record.cancel(); + cancel_prm = record.reload(); } if (added) { - this.screen.current_record._changed.id = added; + record._changed.id = added; } } else { result = response_id != 'RESPONSE_CANCEL';