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.

42 lines
1.6 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(cloned_action.context.active_ids){
  16. report_xlsx_url += '/' + cloned_action.context.active_ids.join(',');
  17. }else{
  18. report_xlsx_url += '?options=' + encodeURIComponent(JSON.stringify(cloned_action.data));
  19. report_xlsx_url += '&context=' + encodeURIComponent(JSON.stringify(cloned_action.context));
  20. }
  21. self.getSession().get_file({
  22. url: report_xlsx_url,
  23. data: {data: JSON.stringify([
  24. report_xlsx_url,
  25. cloned_action.report_type
  26. ])},
  27. error: crash_manager.rpc_error.bind(crash_manager),
  28. success: function (){
  29. if(cloned_action && options && !cloned_action.dialog){
  30. options.on_close();
  31. }
  32. }
  33. });
  34. framework.unblockUI();
  35. return;
  36. }
  37. return self._super(action, options);
  38. }
  39. });
  40. });