summaryrefslogtreecommitdiff
path: root/addons/report/static/src/js/qwebactionmanager.js
diff options
context:
space:
mode:
authorOlivier Colson <oco@odoo.com>2017-02-27 15:39:30 +0100
committerqdp-odoo <qdp@odoo.com>2017-03-03 15:59:42 +0100
commit410d6a703b434dd45e68adbc45693cc565fd9aa6 (patch)
tree3523b110e988d07b063b2bb9656aee59b8fd2987 /addons/report/static/src/js/qwebactionmanager.js
parent0031f98f1d469a0fcece776ec1d510db374bffa5 (diff)
[IMP] report: allow generating multiple reports with one single action returned to js
That is useful in l10n_ch where we need to generate ISR and invoice simultaneously
Diffstat (limited to 'addons/report/static/src/js/qwebactionmanager.js')
-rw-r--r--addons/report/static/src/js/qwebactionmanager.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/addons/report/static/src/js/qwebactionmanager.js b/addons/report/static/src/js/qwebactionmanager.js
index 4bd7b8c89ea..c7d5933b219 100644
--- a/addons/report/static/src/js/qwebactionmanager.js
+++ b/addons/report/static/src/js/qwebactionmanager.js
@@ -98,12 +98,26 @@ ActionManager.include({
if (state === 'upgrade' || state === 'ok') {
// Trigger the download of the PDF report.
- var response = [
- report_urls['qweb-pdf'],
- action.report_type,
- ];
+ var response;
var c = crash_manager;
- return trigger_download(self.session, response, c, action, options);
+
+ var treated_actions = [];
+ var current_action = action;
+ do {
+ report_urls = make_report_url(current_action);
+ response = [
+ report_urls['qweb-pdf'],
+ action.report_type, //The 'root' report is considered the maine one, so we use its type for all the others.
+ ];
+ trigger_download(self.session, response, c, current_action, options);
+
+ treated_actions.push(current_action)
+ current_action = current_action.next_report_to_generate;
+ } while (current_action != null && !treated_actions.includes(current_action))
+ //Second part of the condition for security reasons (avoids infinite loop possibilty).
+
+ return;
+
} else {
// Open the report in the client action if generating the PDF is not possible.
var client_action_options = _.extend({}, options, {
@@ -127,7 +141,8 @@ ActionManager.include({
];
var c = crash_manager;
return trigger_download(self.session, response, c, action, options);
- } else {
+ }
+ else {
return self._super(action, options);
}
}