mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
Manage context, domain, search, tab_domain in action window
This commit is contained in:
parent
6a88f8a638
commit
d64fdd4d8f
|
@ -29,13 +29,54 @@
|
|||
} else if (!jQuery.isEmptyObject(action.view_id)) {
|
||||
params.view_ids = [action.view_id[0]];
|
||||
}
|
||||
// TODO context, domain, search, tab_domain
|
||||
|
||||
if (action.pyson_domain === undefined) {
|
||||
action.pyson_domain = '[]';
|
||||
}
|
||||
var ctx = {
|
||||
active_model: data.res_model,
|
||||
active_id: data.id || false,
|
||||
active_ids: data.ids
|
||||
};
|
||||
var session = Sao.Session.current_session;
|
||||
ctx = jQuery.extend(ctx, session.context);
|
||||
var eval_ctx = jQuery.extend({}, ctx);
|
||||
eval_ctx._user = session.user_id;
|
||||
params.action_ctx = new Sao.PYSON.Decoder(eval_ctx).decode(
|
||||
action.pyson_context || '{}');
|
||||
ctx = jQuery.extend(ctx, params.action_ctx);
|
||||
ctx = jQuery.extend(ctx, context);
|
||||
|
||||
var domain_context = jQuery.extend({}, ctx);
|
||||
domain_context.context = ctx;
|
||||
domain_context._user = session.user_id;
|
||||
params.domain = new Sao.PYSON.Decoder(domain_context).decode(
|
||||
action.pyson_domain);
|
||||
|
||||
var search_context = jQuery.extend({}, ctx);
|
||||
search_context.context = ctx;
|
||||
search_context._user = session.user_id;
|
||||
params.search_value = new Sao.PYSON.Decoder(search_context)
|
||||
.decode(action.pyson_search_value || '[]');
|
||||
|
||||
var tab_domain_context = jQuery.extend({}, ctx);
|
||||
tab_domain_context.context = ctx;
|
||||
tab_domain_context._user = session.user_id;
|
||||
var decoder = new Sao.PYSON.Decoder(tab_domain_context);
|
||||
params.tab_domain = [];
|
||||
action.domains.forEach(function(element, index) {
|
||||
params.tab_domain.push(
|
||||
[element[0], decoder.decode(element[1])]);
|
||||
});
|
||||
params.name = false;
|
||||
if (action.window_name) {
|
||||
params.name = action.name;
|
||||
}
|
||||
params.model = action.res_model || data.res_model;
|
||||
params.res_id = action.res_id || data.res_id;
|
||||
params.limit = action.limit;
|
||||
params.auto_refresh = action.auto_refresh;
|
||||
params.icon = action['icon.rec_name'] || '';
|
||||
Sao.Tab.create(params);
|
||||
return;
|
||||
case 'ir.action.wizard':
|
||||
|
|
|
@ -34,4 +34,7 @@ var Sao = {};
|
|||
};
|
||||
|
||||
Sao.Decimal = Number;
|
||||
|
||||
Sao.config = {};
|
||||
Sao.config.limit = 1000;
|
||||
}());
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
this.model_name = model_name;
|
||||
this.model = new Sao.Model(model_name, attributes);
|
||||
this.attributes = jQuery.extend({}, attributes);
|
||||
this.attributes.limit = this.attributes.limit || Sao.config.limit;
|
||||
this.view_ids = jQuery.extend([], attributes.view_ids);
|
||||
this.view_to_load = jQuery.extend([],
|
||||
attributes.mode || ['tree', 'form']);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
this.login = login;
|
||||
this.user_id = null;
|
||||
this.session = null;
|
||||
this.context = {}; // TODO fill
|
||||
if (!Sao.Session.current_session) {
|
||||
Sao.Session.current_session = this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue