[merge] improvements about reports
bzr revid: nicolas.vanhoren@openerp.com-20110829155356-1nn0hukxug8pzw3k
This commit is contained in:
commit
0cf047e646
|
@ -9,6 +9,7 @@ import re
|
|||
import simplejson
|
||||
import textwrap
|
||||
import xmlrpclib
|
||||
import time
|
||||
from xml.etree import ElementTree
|
||||
from cStringIO import StringIO
|
||||
|
||||
|
@ -20,6 +21,8 @@ import openerpweb.nonliterals
|
|||
|
||||
from babel.messages.pofile import read_po
|
||||
|
||||
_REPORT_POLLER_DELAY = 0.05
|
||||
|
||||
# Should move to openerpweb.Xml2Json
|
||||
class Xml2Json:
|
||||
# xml2json-direct
|
||||
|
@ -1275,3 +1278,25 @@ class Export(View):
|
|||
return export_xls(field, result)
|
||||
else:
|
||||
return export_csv(field, result)
|
||||
|
||||
class Export(View):
|
||||
_cp_path = "/base/report"
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_report(self, req, action):
|
||||
report_srv = req.session.proxy("report")
|
||||
context = req.session.eval_context(openerpweb.nonliterals.CompoundContext(req.context, \
|
||||
action["context"]))
|
||||
|
||||
args = [req.session._db, req.session._uid, req.session._password, action["report_name"], context["active_ids"], {"id": context["active_id"], "model": context["active_model"], "report_type": action["report_type"]}, context]
|
||||
report_id = report_srv.report(*args)
|
||||
report = None
|
||||
while True:
|
||||
args2 = [req.session._db, req.session._uid, req.session._password, report_id]
|
||||
report = report_srv.report_get(*args2)
|
||||
if report["state"]:
|
||||
break
|
||||
time.sleep(_REPORT_POLLER_DELAY)
|
||||
|
||||
#TODO: ok now we've got the report, and so what?
|
||||
return False
|
||||
|
|
|
@ -1565,14 +1565,16 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
|
|||
var self = this;
|
||||
if (!self.value)
|
||||
return;
|
||||
self.rpc("/base/action/load", {
|
||||
action_id: related[2].id,
|
||||
context: {
|
||||
var additional_context = {
|
||||
active_id: self.value[0],
|
||||
active_ids: [self.value[0]],
|
||||
active_model: self.field.relation
|
||||
}
|
||||
};
|
||||
self.rpc("/base/action/load", {
|
||||
action_id: related[2].id,
|
||||
context: additional_context
|
||||
}, function(result) {
|
||||
result.result.context = _.extend(result.result.context || {}, additional_context);
|
||||
self.do_action(result.result);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -123,6 +123,14 @@ openerp.base.ActionManager = openerp.base.Widget.extend({
|
|||
this.content_stop();
|
||||
var ClientWidget = openerp.base.client_actions.get_object(action.tag);
|
||||
(this.client_widget = new ClientWidget(this, action.params)).appendTo(this);
|
||||
},
|
||||
ir_actions_report_xml: function(action) {
|
||||
this.rpc('/base/report/get_report', {
|
||||
action: action,
|
||||
context: {}
|
||||
}).then(function(result) {
|
||||
debugger;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -438,14 +446,17 @@ openerp.base.Sidebar = openerp.base.Widget.extend({
|
|||
//TODO niv: maybe show a warning?
|
||||
return false;
|
||||
}
|
||||
var additional_context = {
|
||||
active_id: ids[0],
|
||||
active_ids: ids,
|
||||
active_model: self.widget_parent.dataset.model
|
||||
};
|
||||
self.rpc("/base/action/load", {
|
||||
action_id: item.action.id,
|
||||
context: {
|
||||
active_id: ids[0],
|
||||
active_ids: ids,
|
||||
active_model: self.widget_parent.dataset.model
|
||||
}
|
||||
context: additional_context
|
||||
}, function(result) {
|
||||
result.result.context = _.extend(result.result.context || {},
|
||||
additional_context);
|
||||
result.result.flags = result.result.flags || {};
|
||||
result.result.flags.new_window = true;
|
||||
self.do_action(result.result);
|
||||
|
|
Loading…
Reference in New Issue