Decode board action the same way as window action

The evaluation code should be the same to ensure same behavior.

issue9275
review303761007
This commit is contained in:
Cédric Krier
2020-06-19 00:20:27 +02:00
parent eda93a21ed
commit 4f21458068
+73 -73
View File
@@ -62,81 +62,10 @@
if (context === undefined) {
context = {};
}
var model, action_prm, act_window;
var decoder, search_context, search_value;
var session = Sao.Session.current_session;
this.name = attributes.name;
this.context = jQuery.extend({}, context);
act_window = new Sao.Model('ir.action.act_window');
this.action_prm = act_window.execute('get', [this.name],
this.context);
this.action_prm.done(function(action) {
var i, len;
var view_ids, decoder, search_context;
var screen_attributes, action_modes;
this.action = action;
this.action.mode = [];
view_ids = [];
if ((this.action.views || []).length > 0) {
for (i = 0, len = this.action.views.length; i < len; i++) {
view_ids.push(this.action.views[i][0]);
this.action.mode.push(this.action.views[i][1]);
}
} else if (this.action.view_id !== undefined) {
view_ids = [this.action.view_id[0]];
}
if ('mode' in attributes) {
this.action.mode = attributes.mode;
}
if (!('pyson_domain' in this.action)) {
this.action.pyson_domain = '[]';
}
jQuery.extend(this.context,
Sao.Session.current_session.context);
this.context._user = Sao.Session.current_session.user_id;
decoder = new Sao.PYSON.Decoder(this.context);
jQuery.extend(this.context,
decoder.decode(this.action.pyson_context || '{}'));
decoder = new Sao.PYSON.Decoder(this.context);
jQuery.extend(this.context,
decoder.decode(this.action.pyson_context || '{}'));
this.domain = [];
this.update_domain([]);
search_context = jQuery.extend({}, this.context);
search_context.context = this.context;
search_context._user = Sao.Session.current_session.user_id;
decoder = new Sao.PYSON.Decoder(search_context);
search_value = decoder.decode(
this.action.pyson_search_value || '[]');
screen_attributes = {
mode: this.action.mode,
context: this.context,
view_ids: view_ids,
domain: this.domain,
search_value: search_value,
row_activate: this.row_activate.bind(this),
};
this.screen = new Sao.Screen(this.action.res_model,
screen_attributes);
if (attributes.string) {
this.title.html(attributes.string);
} else {
this.title.html(this.action.name);
}
this.screen.switch_view().done(function() {
this.body.append(this.screen.screen_container.el);
this.screen.search_filter();
}.bind(this));
}.bind(this));
this.el = jQuery('<div/>', {
'class': 'board-action panel panel-default',
});
@@ -148,6 +77,75 @@
'class': 'panel-body',
});
this.el.append(this.body);
var act_window = new Sao.Model('ir.action.act_window');
this.action_prm = act_window.execute('get', [this.name], {});
this.action_prm.done(function(action) {
var params = {};
this.action = action;
params.view_ids = [];
params.mode = null;
if (!jQuery.isEmptyObject(action.views)) {
params.view_ids = [];
params.mode = [];
action.views.forEach(function(x) {
params.view_ids.push(x[0]);
params.mode.push(x[1]);
});
} else if (!jQuery.isEmptyObject(action.view_id)) {
params.view_ids = [action.view_id[0]];
}
if (!('pyson_domain' in this.action)) {
this.action.pyson_domain = '[]';
}
var ctx = {};
ctx = jQuery.extend(ctx, session.context);
ctx._user = session.user_id;
var decoder = new Sao.PYSON.Decoder(ctx);
params.context = jQuery.extend(
{}, context,
decoder.decode(action.pyson_context || '{}'));
ctx = jQuery.extend(ctx, params.context);
ctx.context = ctx;
decoder = new Sao.PYSON.Decoder(ctx);
params.domain = decoder.decode(action.pyson_domain);
params.order = decoder.decode(action.pyson_order);
params.search_value = decoder.decode(
action.pyson_search_value || '[]');
params.tab_domain = [];
action.domains.forEach(function(element, index) {
params.tab_domain.push(
[element[0], decoder.decode(element[1]), element[2]]);
});
params.context_model = action.context_model;
params.context_domain = action.context_domain;
if (action.limit !== null) {
params.limit = action.limit;
} else {
params.limit = Sao.config.limit;
}
this.context = ctx;
this.domain = [];
this.update_domain([]);
params.row_activate = this.row_activate.bind(this);
this.screen = new Sao.Screen(this.action.res_model,
params);
if (attributes.string) {
this.title.html(attributes.string);
} else {
this.title.html(this.action.name);
}
this.screen.switch_view().done(function() {
this.body.append(this.screen.screen_container.el);
this.screen.search_filter();
}.bind(this));
}.bind(this));
},
row_activate: function() {
var record_ids, win;
@@ -172,7 +170,9 @@
} else {
this.screen.current_record.cancel();
}
}.bind(this));
}.bind(this), {
'title': this.title.text(),
});
}
},
set_value: function() {