Open new tab if the current view of existing tab is not the first one

User expect that action will open a tab on the first/default view even if an
existing tab exists with a different view.

Closes #9086
This commit is contained in:
Cédric Krier committed 2024-02-21 16:47:19 +01:00
1 parent 0f06ca9142
commit 2ae89396c3
4 files changed
+14 -4

No files matched your search

+4 -2
View File
@@ -925,6 +925,9 @@
get number_of_views() {
return this.views.length + this.view_to_load.length;
},
get view_index() {
return this.views.indexOf(this.current_view);
},
switch_view: function(
view_type=null, view_id=null, creatable=null, display=true) {
if (view_id !== null) {
@@ -1001,9 +1004,8 @@
return this.add_view_id(view_id, view_type)
.then(set_current_view);
} else {
var i = this.views.indexOf(this.current_view);
this.current_view = this.views[
(i + 1) % this.views.length];
(this.view_index + 1) % this.views.length];
}
if (found()) {
break;
+3 -1
View File
@@ -784,7 +784,9 @@
return false;
}
var compare = Sao.common.compare;
return ((this.screen.model_name === attributes.model) &&
return (
(this.screen.view_index === 0) &&
(this.screen.model_name === attributes.model) &&
(this.attributes.res_id === attributes.res_id) &&
(compare(
this.attributes.domain || [], attributes.domain || [])) &&
+3 -1
View File
@@ -105,7 +105,9 @@ class Form(TabContent):
def compare(self, model, attributes):
if not attributes:
return False
return (self.model == model
return (
self.screen.view_index == 0
and self.model == model
and self.res_id == attributes.get('res_id')
and self.attributes.get('domain') == attributes.get('domain')
and self.attributes.get('view_ids') == attributes.get('view_ids')
@@ -538,6 +538,10 @@ class Screen:
def number_of_views(self):
return len(self.views) + len(self.view_to_load)
@property
def view_index(self):
return self.__current_view
def switch_view(
self, view_type=None, view_id=None, creatable=None, display=True):
if view_id is not None: