Fallback to model name as title

issue9596
review300381002
This commit is contained in:
Cédric Krier
2020-10-04 00:35:23 +02:00
parent 4f5c7d8af2
commit 137852452e
5 changed files with 43 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
* Fallback to model name as title
* Set treeview footer sticky on bottom
* Add get, in_ and contains methods to PYSON
* Manage deletable and writable state
+22
View File
@@ -496,6 +496,28 @@
});
Sao.common.MODELHISTORY = new Sao.common.ModelHistory();
Sao.common.ModelName = Sao.class_(Object, {
init: function() {
this._names = {};
},
load_names: function() {
this._names = Sao.rpc({
'method':'model.ir.model.get_names',
'params': [{}],
}, Sao.Session.current_session, false);
},
get: function(model) {
if (jQuery.isEmptyObject(this._names)) {
this.load_names();
}
return this._names[model] || '';
},
clear: function() {
this._names = {};
},
});
Sao.common.MODELNAME = new Sao.common.ModelName();
Sao.common.ViewSearch = Sao.class_(Object, {
init: function() {
this.encoder = new Sao.PYSON.Encoder();
+1
View File
@@ -376,6 +376,7 @@ var Sao = {};
});
Sao.i18n.set_direction(preferences.language_direction);
Sao.i18n.locale = preferences.locale;
Sao.common.MODELNAME.clear();
return prm;
});
});
+11 -3
View File
@@ -465,7 +465,11 @@
this.view_prm = this.screen.switch_view().done(function() {
this.screen.count_tab_domain();
this.set_name(attributes.name || '');
var name = attributes.name;
if (!name) {
name = Sao.common.MODELNAME.get(model_name);
}
this.set_name(name);
this.content.append(screen.screen_container.el);
if (attributes.res_id) {
if (!jQuery.isArray(attributes.res_id)) {
@@ -1370,7 +1374,7 @@
new Sao.Window.Import(this.title.text(), this.screen);
},
get_url: function() {
return this.screen.get_url(this.attributes.name);
return this.screen.get_url(this.name);
},
});
@@ -1383,7 +1387,11 @@
this.view_id = (attributes.view_ids.length > 0 ?
attributes.view_ids[0] : null);
this.context = attributes.context;
this.name = attributes.name || '';
var name = attributes.name;
if (!name) {
name = Sao.common.MODELNAME.get(this.model);
}
this.name = name;
this.dialogs = [];
this.board = null;
UIView = new Sao.Model('ir.ui.view');
+8 -1
View File
@@ -94,6 +94,9 @@
this.save_current = kwargs.save_current;
var title_prm = jQuery.when(kwargs.title || '');
title_prm.then(function(title) {
if (!title) {
title = Sao.common.MODELNAME.get(this.screen.model_name);
}
this.title = title;
}.bind(this));
@@ -638,7 +641,11 @@
this.views_preload = views_preload;
this.sel_multi = kwargs.sel_multi;
this.callback = callback;
this.title = kwargs.title || '';
var title = kwargs.title;
if (!title) {
title = Sao.common.MODELNAME.get(model);
}
this.title = title;
this.exclude_field = kwargs.exclude_field || null;
var dialog = new Sao.Dialog(Sao.i18n.gettext(
'Search %1', this.title), '', 'lg');