return module_installed(req)
@openerpweb.jsonrequest
- def eval_domain_and_context(self, req, contexts, domains,
- group_by_seq=None):
- """ Evaluates sequences of domains and contexts, composing them into
- a single context, domain or group_by sequence.
-
- :param list contexts: list of contexts to merge together. Contexts are
- evaluated in sequence, all previous contexts
- are part of their own evaluation context
- (starting at the session context).
- :param list domains: list of domains to merge together. Domains are
- evaluated in sequence and appended to one another
- (implicit AND), their evaluation domain is the
- result of merging all contexts.
- :param list group_by_seq: list of domains (which may be in a different
- order than the ``contexts`` parameter),
- evaluated in sequence, their ``'group_by'``
- key is extracted if they have one.
- :returns:
- a 3-dict of:
-
- context (``dict``)
- the global context created by merging all of
- ``contexts``
-
- domain (``list``)
- the concatenation of all domains
-
- group_by (``list``)
- a list of fields to group by, potentially empty (in which case
- no group by should be performed)
- """
- context, domain = eval_context_and_domain(req.session,
- nonliterals.CompoundContext(*(contexts or [])),
- nonliterals.CompoundDomain(*(domains or [])))
-
- group_by_sequence = []
- for candidate in (group_by_seq or []):
- ctx = req.session.eval_context(candidate, context)
- group_by = ctx.get('group_by')
- if not group_by:
- continue
- elif isinstance(group_by, basestring):
- group_by_sequence.append(group_by)
- else:
- group_by_sequence.extend(group_by)
-
- return {
- 'context': context,
- 'domain': domain,
- 'group_by': group_by_sequence
- }
-
- @openerpweb.jsonrequest
def save_session_action(self, req, the_action):
"""
This method store an action object in the session object and returns an integer
as keyword arguments on the Python method [#]_). This function fetches
the return value of the Python methods, converted to JSON.
-For instance, to call the ``eval_domain_and_context`` of the
-:class:`~web.controllers.main.Session` controller:
+For instance, to call the ``resequence`` of the
+:class:`~web.controllers.main.DataSet` controller:
.. code-block:: javascript
- openerp.connection.rpc('/web/session/eval_domain_and_context', {
- domains: ds,
- contexts: cs
+ openerp.connection.rpc('/web/dataset/resequence', {
+ model: some_model,
+ ids: array_of_ids,
+ offset: 42
}).then(function (result) {
- // handle result
+ // resequenced on server
});
.. [#] with a small twist: SQLAlchemy's ``orm.query.Query.group_by``
var deferred = $.Deferred();
if (! options.shadow)
this.trigger('request', url, payload);
- var request;
-// if (url.url === '/web/session/eval_domain_and_context') {
-// // intercept eval_domain_and_context
-// request = instance.web.pyeval.eval_domains_and_contexts(
-// params)
-// } else {
- request = this.rpc_function(url, payload);
-// }
- request.then(
+
+ this.rpc_function(url, payload).then(
function (response, textStatus, jqXHR) {
if (! options.shadow)
self.trigger('response', response);
instance.web.pyeval.eval_domains_and_contexts = function (source) {
return new $.Deferred(function (d) {setTimeout(function () {
try {
- var contexts = ([instance.session.context] || []).concat(source.contexts);
+ var contexts = ([instance.session.user_context] || []).concat(source.contexts);
// see Session.eval_context in Python
- d.resolve({result: {
+ d.resolve({
context: instance.web.pyeval.eval('contexts', contexts),
domain: instance.web.pyeval.eval('domains', source.domains),
- group_by: instance.web.pyeval.eval('groupbys', source.group_by_seq)
- }}, 'success', {});
+ group_by: instance.web.pyeval.eval('groupbys', source.group_by_seq || [])
+ });
} catch (e) {
d.resolve({ error: {
code: 400,
var set_as_default = this.$('#oe_searchview_custom_default').prop('checked');
var search = this.view.build_search_data();
- this.rpc('/web/session/eval_domain_and_context', {
+ instance.web.pyeval.eval_domains_and_contexts({
domains: search.domains,
contexts: search.contexts,
group_by_seq: search.groupbys || []
var self = this;
this.init_dataset();
if (this.options.initial_view == "search") {
- self.rpc('/web/session/eval_domain_and_context', {
+ instance.web.pyeval.eval_domains_and_contexts({
domains: [],
contexts: [this.context]
}).done(function (results) {
},
do_search: function(domains, contexts, groupbys) {
var self = this;
- this.rpc('/web/session/eval_domain_and_context', {
+ instance.web.pyeval.eval_domains_and_contexts({
domains: domains || [],
contexts: contexts || [],
group_by_seq: groupbys || []
if (action.context) {
c.add(action.context);
}
- return self.rpc('/web/session/eval_domain_and_context', {
+ return instance.web.pyeval.eval_domains_and_contexts({
contexts: [c], domains: []
}).then(function (res) {
action.context = res.context;
ir_actions_report_xml: function(action, options) {
var self = this;
instance.web.blockUI();
- self.rpc("/web/session/eval_domain_and_context", {
+ instance.web.pyeval.eval_domains_and_contexts({
contexts: [action.context],
domains: []
}).done(function(res) {
var self = this,
controller = this.views[this.active_view].controller,
action_context = this.action.context || {};
- this.rpc('/web/session/eval_domain_and_context', {
+ instance.web.pyeval.eval_domains_and_contexts({
domains: [this.action.domain || []].concat(domains || []),
contexts: [action_context].concat(contexts || []),
group_by_seq: groupbys || []
});
}
ncontext.add(action.context || {});
- return self.rpc('/web/session/eval_domain_and_context', {
+ return instance.web.pyeval.eval_domains_and_contexts({
contexts: [ncontext],
domains: []
}).then(function (results) {
dependencies: ['web.data'],
rpc: 'rpc',
setup: function (instance) {
+ instance.session.user_context = {
+ lang: 'en_US',
+ tz: false,
+ uid: 1
+ };
instance.edc = function (domains, contexts) {
- return this.session.rpc('/web/session/eval_domain_and_context', {
+ return instance.web.pyeval.eval_domains_and_contexts({
contexts: contexts || [],
domains: domains || []
});
dependencies: ['web.data'],
rpc: 'rpc',
setup: function (instance) {
+ instance.session.user_context = {
+ lang: 'en_US',
+ tz: false,
+ uid: 1
+ };
_.extend(instance, {
edc: function (domains, contexts) {
- return this.session.rpc('/web/session/eval_domain_and_context', {
+ return instance.web.pyeval.eval_domains_and_contexts({
contexts: contexts || [],
domains: domains || []
});
});
}
}, function (test) {
- test('domain with time', {asserts: 2}, function (instance) {
+ test('domain with time', {asserts: 1}, function (instance) {
return instance.load_domain(0).then(function (d) {
strictEqual(d.__ref, 'domain');
return instance.edc([
},
d,
[['user_id', '=', 1]]
- ])
+ ]);
}).then(function (result) {
var d = new Date();
var today = _.str.sprintf("%04d-%02d-%02d",