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.

51 lines
1.6 KiB

  1. odoo.define("account_financial_report.client_action", function(require) {
  2. "use strict";
  3. var ReportAction = require("report.client_action");
  4. var core = require("web.core");
  5. var QWeb = core.qweb;
  6. const AFRReportAction = ReportAction.extend({
  7. start: function() {
  8. return this._super.apply(this, arguments).then(() => {
  9. this.$buttons = $(
  10. QWeb.render(
  11. "account_financial_report.client_action.ControlButtons",
  12. {}
  13. )
  14. );
  15. this.$buttons.on("click", ".o_report_print", this.on_click_print);
  16. this.$buttons.on("click", ".o_report_export", this.on_click_export);
  17. this._update_control_panel();
  18. });
  19. },
  20. on_click_export: function() {
  21. const action = {
  22. type: "ir.actions.report",
  23. report_type: "xlsx",
  24. report_name: this._get_xlsx_name(this.report_name),
  25. report_file: this._get_xlsx_name(this.report_file),
  26. data: this.data,
  27. context: this.context,
  28. display_name: this.title,
  29. };
  30. return this.do_action(action);
  31. },
  32. /**
  33. * @param {String} str
  34. * @returns {String}
  35. */
  36. _get_xlsx_name: function(str) {
  37. const parts = str.split(".");
  38. return `a_f_r.report_${parts[parts.length - 1]}_xlsx`;
  39. },
  40. });
  41. core.action_registry.add("account_financial_report.client_action", AFRReportAction);
  42. return AFRReportAction;
  43. });