Do not fail to reload modified view without a current record

It may happen that a tree view is considered as modified even if there is no
current record. In this case we should not try to compare the id of the current
record before and after reload as it is not defined.

Closes #13998
This commit is contained in:
Cédric Krier committed 2025-05-05 12:33:01 +02:00
1 parent 4b906352b1
commit 4bda4705f1
2 files changed
+21 -13

No files matched your search

+13 -8
View File
@@ -861,15 +861,20 @@
case 'ok':
return this.save();
case 'ko':
var record_id = this.screen.current_record.id;
var record_id = null;
if (this.screen.current_record) {
record_id = this.screen.current_record.id;
}
return this.reload(false).then(() => {
if (record_id < 0) {
return jQuery.Deferred().reject(true);
}
else if (this.screen.current_record) {
if (record_id !=
this.screen.current_record.id) {
return jQuery.Deferred().reject();
if (record_id !== null) {
if (record_id < 0) {
return jQuery.Deferred().reject(true);
}
else if (this.screen.current_record) {
if (record_id !=
this.screen.current_record.id) {
return jQuery.Deferred().reject();
}
}
}
});
+8 -5
View File
@@ -679,12 +679,15 @@ class Form(TabContent):
if value == 'ok':
return self.sig_save(None)
if value == 'ko':
record_id = self.screen.current_record.id
record_id = None
if self.screen.current_record:
record_id = self.screen.current_record.id
if self.sig_reload(test_modified=False):
if record_id < 0:
return None
elif self.screen.current_record:
return record_id == self.screen.current_record.id
if record_id is not None:
if record_id < 0:
return None
elif self.screen.current_record:
return record_id == self.screen.current_record.id
return False
return True