[IMP]: Print workflow report

bzr revid: aja@tinyerp.com-20120912104214-z34o1hyk2qt67jhu
This commit is contained in:
ajay javiya (OpenERP)
2012-09-12 16:12:14 +05:30
parent 6c542b0330
commit 5a9c2544ef
2 changed files with 41 additions and 2 deletions
+26 -2
View File
@@ -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"
+15
View File
@@ -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) {