OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

  1. /* Copyright 2017 ACSONE SA/NV
  2. * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
  3. odoo.define('report_py3o.report', function (require) {
  4. var ActionManager = require('web.ActionManager');
  5. var core = require('web.core');
  6. var crash_manager = require('web.crash_manager');
  7. var framework = require('web.framework');
  8. var session = require('web.session');
  9. var _t = core._t;
  10. var trigger_download = function(session, response, c, action, options) {
  11. session.get_file({
  12. url: '/report/download',
  13. data: {data: JSON.stringify(response)},
  14. complete: framework.unblockUI,
  15. error: c.rpc_error.bind(c),
  16. success: function(){
  17. if (action && options && !action.dialog) {
  18. options.on_close();
  19. }
  20. },
  21. });
  22. };
  23. ActionManager.include({
  24. ir_actions_report_xml: function(action, options) {
  25. var self = this;
  26. // Py3o reports
  27. if ('report_type' in action && action.report_type == 'py3o' ) {
  28. framework.blockUI();
  29. action = _.clone(action);
  30. _t = core._t;
  31. var report_url = '/report/py3o/' + action.report_name;;
  32. // generic report: no query string
  33. // particular: query string of action.data.form and context
  34. if (!('data' in action) || !(action.data)) {
  35. if ('active_ids' in action.context) {
  36. report_url += "/" + action.context.active_ids.join(',');
  37. }
  38. } else {
  39. report_url += "&options=" + encodeURIComponent(JSON.stringify(action.data));
  40. report_url += "&context=" + encodeURIComponent(JSON.stringify(action.context));
  41. }
  42. var response = new Array();
  43. response[0] = report_url;
  44. response[1] = action.report_type;
  45. var c = crash_manager;
  46. return trigger_download(self.session, response, c, action, options);
  47. } else {
  48. return self._super(action, options);
  49. }
  50. }
  51. });
  52. });