[IMP]: Print workflow report
bzr revid: aja@tinyerp.com-20120912104214-z34o1hyk2qt67jhu
This commit is contained in:
@@ -1937,9 +1937,33 @@ class Reports(View):
|
||||
# maybe we should take of what characters can appear in a file name?
|
||||
('Content-Disposition', 'attachment; filename="%s.%s"' % (file_name, report_struct['format'])),
|
||||
('Content-Type', report_mimetype),
|
||||
('Content-Length', len(report))],
|
||||
cookies={'fileToken': int(token)})
|
||||
('Content-Length', len(report))],)
|
||||
|
||||
@openerpweb.httprequest
|
||||
def print_workflow(self, req, action, token):
|
||||
action = simplejson.loads(action)
|
||||
report_srv = req.session.proxy("report")
|
||||
action.update({'nested': True})
|
||||
report_id = report_srv.report(
|
||||
req.session._db, req.session._uid, req.session._password,
|
||||
'workflow.instance.graph', action['id'], action)
|
||||
report_struct = None
|
||||
while True:
|
||||
report_struct = report_srv.report_get(
|
||||
req.session._db, req.session._uid,
|
||||
req.session._password, report_id)
|
||||
if report_struct["state"]:
|
||||
break
|
||||
time.sleep(self.POLLING_DELAY)
|
||||
report = base64.b64decode(report_struct['result'])
|
||||
file_name = 'workflow_%s_%d.%s'%(action['model'], action['id'], report_struct['format'])
|
||||
return req.make_response(report,
|
||||
headers=[
|
||||
('Content-Disposition', 'attachment; filename="%s"'% (file_name)),
|
||||
('Content-Type', 'application/pdf'),
|
||||
('Content-Length', len(report))],
|
||||
cookies={'fileToken': int(token)})
|
||||
|
||||
class Import(View):
|
||||
_cp_path = "/web/import"
|
||||
|
||||
|
||||
@@ -837,6 +837,21 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
|
||||
});
|
||||
break;
|
||||
case 'print_workflow':
|
||||
var self = this
|
||||
if (current_view.get_selected_ids().length != 1) {
|
||||
instance.web.dialog($("<div />").text(_t("You must choose only one record.")), { title: _t("Warning"), modal: true });
|
||||
evt.currentTarget.selectedIndex = 0;
|
||||
return false;
|
||||
} else {
|
||||
instance.web.blockUI();
|
||||
var action={"id":current_view.get_selected_ids()[0],
|
||||
"model":self.dataset.model}
|
||||
self.session.get_file({
|
||||
url: '/web/report/print_workflow',
|
||||
data: {action: JSON.stringify(action)},
|
||||
complete: instance.web.unblockUI
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (val) {
|
||||
|
||||
Reference in New Issue
Block a user