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.

47 lines
1.8 KiB

  1. // © 2017 Creu Blanca
  2. // License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
  3. odoo.define('report_xlsx.report', function(require){
  4. 'use strict';
  5. var ActionManager= require('web.ActionManager');
  6. var crash_manager = require('web.crash_manager');
  7. var framework = require('web.framework');
  8. ActionManager.include({
  9. ir_actions_report: function (action, options){
  10. var self = this;
  11. var cloned_action = _.clone(action);
  12. if (cloned_action.report_type === 'xlsx') {
  13. framework.blockUI();
  14. var report_xlsx_url = 'report/xlsx/' + cloned_action.report_name;
  15. if (_.isUndefined(cloned_action.data) ||
  16. _.isNull(cloned_action.data) ||
  17. (_.isObject(cloned_action.data) && _.isEmpty(cloned_action.data)))
  18. {
  19. if(cloned_action.context.active_ids) {
  20. report_xlsx_url += '/' + cloned_action.context.active_ids.join(',');
  21. }
  22. } else {
  23. report_xlsx_url += '?options=' + encodeURIComponent(JSON.stringify(cloned_action.data));
  24. report_xlsx_url += '&context=' + encodeURIComponent(JSON.stringify(cloned_action.context));
  25. }
  26. self.getSession().get_file({
  27. url: report_xlsx_url,
  28. data: {data: JSON.stringify([
  29. report_xlsx_url,
  30. cloned_action.report_type
  31. ])},
  32. error: crash_manager.rpc_error.bind(crash_manager),
  33. success: function (){
  34. if(cloned_action && options && !cloned_action.dialog){
  35. options.on_close();
  36. }
  37. }
  38. });
  39. framework.unblockUI();
  40. return;
  41. }
  42. return self._super(action, options);
  43. }
  44. });
  45. });