Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sao/src/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,11 @@
if (this.group.parent) {
this.order = null;
}
this.current_record = null;
if (group && (group.length > 0)) {
this.current_record = group[0];
} else {
this.current_record = null;
}
this.group.add_fields(fields);
for (name in fields_views) {
var views = fields_views[name];
Expand Down Expand Up @@ -1322,7 +1326,11 @@
load: function(ids, set_cursor=true, modified=false, position=-1) {
this.group.load(ids, null, modified, position);
this.current_view.reset();
this.current_record = null;
if ((ids.length > 0) && (this.current_view.view_type == 'tree')) {
this.current_record = this.group.get(ids[0]);
} else {
this.current_record = null;
}
return this.display().then(() => {
if (set_cursor) {
this.set_cursor();
Expand Down Expand Up @@ -1376,7 +1384,7 @@
if (this.current_record &&
~this.current_record.group.indexOf(this.current_record)) {
} else if (this.group && this.group.length &&
(this.current_view.view_type == 'form')) {
(['form', 'tree'].includes(this.current_view.view_type))) {
this.current_record = this.group[0];
} else {
this.current_record = null;
Expand Down
14 changes: 10 additions & 4 deletions tryton/tryton/gui/window/view_form/screen/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ def __set_group(self, group):
self.filter_widget = None
self.order = None
self.__group.add_fields(fields)
self.current_record = None
if group:
self.current_record = group[0]
else:
self.current_record = None
for name, views in fields_views.items():
self.__group.fields[name].views.update(views)
self.__group.exclude_field = self.exclude_field
Expand Down Expand Up @@ -1007,18 +1010,21 @@ def get_tree_domain(self, parent):
def load(self, ids, set_cursor=True, modified=False, position=-1):
self.group.load(ids, modified=modified, position=position)
self.current_view.reset()
self.current_record = None
if ids and self.current_view.view_type == 'tree':
self.current_record = self.group.get(ids[0])
else:
self.current_record = None
self.display(set_cursor=set_cursor)

def display(self, res_id=None, set_cursor=False, force=False):
start = time.time()
if res_id:
self.current_record = self.group.get(res_id)
else:
if (self.current_record
and self.current_record in self.current_record.group):
pass
elif self.group and self.current_view.view_type == 'form':
elif (self.group
and self.current_view.view_type in {'form', 'tree'}):
self.current_record = self.group[0]
else:
self.current_record = None
Expand Down