From 8f3d096dbae18bacd95796d03b17d4d94a806c85 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 13 Sep 2022 12:05:33 +0700 Subject: jasper report integration --- jasper_reports/static/description/apps.png | Bin 0 -> 28791 bytes .../static/description/create_report.png | Bin 0 -> 23646 bytes .../static/description/data_template.png | Bin 0 -> 9159 bytes jasper_reports/static/description/example.png | Bin 0 -> 205242 bytes jasper_reports/static/description/icon.png | Bin 0 -> 4110 bytes jasper_reports/static/description/index.html | 126 +++++++++++++++++++++ jasper_reports/static/description/jasper_menu.png | Bin 0 -> 83310 bytes .../static/description/jasper_studio.png | Bin 0 -> 187562 bytes jasper_reports/static/description/java_path.png | Bin 0 -> 28631 bytes jasper_reports/static/description/print_report.png | Bin 0 -> 53493 bytes jasper_reports/static/src/img/icon.png | Bin 0 -> 4110 bytes .../static/src/js/report/jasperactionmanager.js | 100 ++++++++++++++++ 12 files changed, 226 insertions(+) create mode 100755 jasper_reports/static/description/apps.png create mode 100755 jasper_reports/static/description/create_report.png create mode 100755 jasper_reports/static/description/data_template.png create mode 100755 jasper_reports/static/description/example.png create mode 100755 jasper_reports/static/description/icon.png create mode 100755 jasper_reports/static/description/index.html create mode 100755 jasper_reports/static/description/jasper_menu.png create mode 100755 jasper_reports/static/description/jasper_studio.png create mode 100755 jasper_reports/static/description/java_path.png create mode 100755 jasper_reports/static/description/print_report.png create mode 100755 jasper_reports/static/src/img/icon.png create mode 100755 jasper_reports/static/src/js/report/jasperactionmanager.js (limited to 'jasper_reports/static') diff --git a/jasper_reports/static/description/apps.png b/jasper_reports/static/description/apps.png new file mode 100755 index 0000000..39dec45 Binary files /dev/null and b/jasper_reports/static/description/apps.png differ diff --git a/jasper_reports/static/description/create_report.png b/jasper_reports/static/description/create_report.png new file mode 100755 index 0000000..42ac20d Binary files /dev/null and b/jasper_reports/static/description/create_report.png differ diff --git a/jasper_reports/static/description/data_template.png b/jasper_reports/static/description/data_template.png new file mode 100755 index 0000000..a72efba Binary files /dev/null and b/jasper_reports/static/description/data_template.png differ diff --git a/jasper_reports/static/description/example.png b/jasper_reports/static/description/example.png new file mode 100755 index 0000000..b9ec346 Binary files /dev/null and b/jasper_reports/static/description/example.png differ diff --git a/jasper_reports/static/description/icon.png b/jasper_reports/static/description/icon.png new file mode 100755 index 0000000..6c41ad6 Binary files /dev/null and b/jasper_reports/static/description/icon.png differ diff --git a/jasper_reports/static/description/index.html b/jasper_reports/static/description/index.html new file mode 100755 index 0000000..74cc7f3 --- /dev/null +++ b/jasper_reports/static/description/index.html @@ -0,0 +1,126 @@ + + + +
+
+

Jasper Report

+

This Module Gives The Features for creating Jasper Reports

+
+

+

+ +
+
+
+ +
+
+

Configure Java path

+

In your Odoo web interface, under the Company Data -> Jasper Configuration, add java path.

+
+

+

+ +
+
+
+ +
+
+

Jasper Report Menu

+

In your Odoo web interface, under the Technical section, jasper reports menu is there.

+
+

+

+ +
+
+
+ +
+
+

Jasper Data Template

+

From your Jasper Menu, Create a jasper reports data template file.

+
+

+

+ +
+
+
+ +
+
+

Design Jasper Report

+

In Jasper Studio, import the .xml file which was generated from Odoo and design your Jasper Report as .jrxml.

+
+

+

+ +
+
+
+ +
+
+

Create Jasper Report

+

Create a jasper reports for your module with your .jrxml file.

+
+

+

+ +
+

Demo reports can be founded in jasper_reports/demo folder.

+
+
+ +
+
+

Print Jasper Report

+
+

+

+ +
+
+
+ +
+
+

Example Of Jasper Report

+
+

+

+ +
+
+
+ +
+
+

Jasper Report 'uuid' error

+
+

+

+ Error:
+
+ "Attribute 'uuid' is not allowed to appear in element 'jasperReport'."

+

+

+
+ Solution:
+
+ Solution 1: Open the .jrxml file created and remove uuid attributes.
+ Solution 2: Go to the Jasper Studio --> 'Window' --> 'Preferences'
+ Jasper Studio --> Compatibility --> In the drop down select/apply 'JasperReports 3.5.1' +
+

+

+
+
+
+ + + + + diff --git a/jasper_reports/static/description/jasper_menu.png b/jasper_reports/static/description/jasper_menu.png new file mode 100755 index 0000000..573fe58 Binary files /dev/null and b/jasper_reports/static/description/jasper_menu.png differ diff --git a/jasper_reports/static/description/jasper_studio.png b/jasper_reports/static/description/jasper_studio.png new file mode 100755 index 0000000..16d82de Binary files /dev/null and b/jasper_reports/static/description/jasper_studio.png differ diff --git a/jasper_reports/static/description/java_path.png b/jasper_reports/static/description/java_path.png new file mode 100755 index 0000000..d3b72b1 Binary files /dev/null and b/jasper_reports/static/description/java_path.png differ diff --git a/jasper_reports/static/description/print_report.png b/jasper_reports/static/description/print_report.png new file mode 100755 index 0000000..77fd821 Binary files /dev/null and b/jasper_reports/static/description/print_report.png differ diff --git a/jasper_reports/static/src/img/icon.png b/jasper_reports/static/src/img/icon.png new file mode 100755 index 0000000..6c41ad6 Binary files /dev/null and b/jasper_reports/static/src/img/icon.png differ diff --git a/jasper_reports/static/src/js/report/jasperactionmanager.js b/jasper_reports/static/src/js/report/jasperactionmanager.js new file mode 100755 index 0000000..57616bf --- /dev/null +++ b/jasper_reports/static/src/js/report/jasperactionmanager.js @@ -0,0 +1,100 @@ +odoo.define('report_xml.report', function (require) { + 'use strict'; + + var ActionManager = require('web.ActionManager'); + var core = require('web.core'); + var framework = require('web.framework'); + var session = require('web.session'); + var _t = core._t; + + ActionManager.include({ + + _executeReportAction: function (action, options) { + var self = this; + if (action.report_type === 'jasper') { + return self._triggerDownload(action, options, 'jasper'); + } + return this._super.apply(this, arguments); + }, + + _downloadReportJasper: function (url) { + var self = this; + framework.blockUI(); + return new Promise(function (resolve, reject) { + var reporttype = url.split('/')[2]; + var type = 'jasper'; + var blocked = !session.get_file({ + url: '/report/download', + data: { + data: JSON.stringify([url, type]), + context: JSON.stringify(session.user_context), + }, + success: resolve, + error: (error) => { + self.call('crash_manager', 'rpc_error', error); + reject(); + }, + complete: framework.unblockUI, + }); + if (blocked) { + // AAB: this check should be done in get_file service directly, + // should not be the concern of the caller (and that way, get_file + // could return a promise) + var message = _t('A popup window with your report was blocked. You ' + + 'may need to change your browser settings to allow ' + + 'popup windows for this page.'); + self.do_warn(_t('Warning'), message, true); + } + }); + }, + + _makeReportUrlsJasper: function (action) { + var reportUrls = this._makeReportUrls(action); + reportUrls.jasper = '/report/jasper/' + action.report_name; + + // We may have to build a query string with `action.data`. It's the place + // were report's using a wizard to customize the output traditionally put + // their options. + if (_.isUndefined(action.data) || _.isNull(action.data) || + (_.isObject(action.data) && _.isEmpty(action.data))) { + if (action.context.active_ids) { + var activeIDsPath = '/' + action.context.active_ids.join(','); + reportUrls = _.mapObject(reportUrls, function (value) { + return value += activeIDsPath; + }); + } + reportUrls.html += '?context=' + encodeURIComponent(JSON.stringify(session.user_context)); + } else { + var serializedOptionsPath = '?options=' + encodeURIComponent(JSON.stringify(action.data)); + serializedOptionsPath += '&context=' + encodeURIComponent(JSON.stringify(action.context)); + reportUrls = _.mapObject(reportUrls, function (value) { + return value += serializedOptionsPath; + }); + } + return reportUrls; + }, + + _triggerDownload: function (action, options, type) { + if (type === "jasper") { + var self = this; + var reportUrls = this._makeReportUrlsJasper(action); + return this._downloadReportJasper( + reportUrls[type]).then(function () { + if (action.close_on_report_download) { + var closeAction = { + type: 'ir.actions.act_window_close' + }; + return self.doAction( + closeAction, _.pick(options, 'on_close')); + } else { + return options.on_close(); + } + } + ); + } + return this._super.apply(this, arguments); + + }, + + }); +}); -- cgit v1.2.3