├── .gitignore ├── COPYING ├── README.md ├── java_server ├── .classpath ├── .project ├── Dockerfile.in ├── WebContent │ ├── META-INF │ │ └── MANIFEST.MF │ └── WEB-INF │ │ └── web.xml ├── build-res │ └── subfloor.xml ├── build.properties ├── build.xml ├── ivy.xml ├── ivysettings.xml └── src │ ├── com │ └── willowit │ │ ├── application │ │ ├── PentahoResourceChecker.java │ │ ├── PentahoResourceManager.java │ │ └── StandaloneReportServer.java │ │ └── reporting │ │ └── PentahoRenderer.java │ ├── log4j.properties │ └── org │ └── apache │ └── xmlrpc │ └── webserver │ └── XmlRpcServlet.properties ├── odoo_addon ├── pentaho_report_scheduler │ ├── __init__.py │ ├── __openerp__.py │ ├── scheduler.py │ ├── scheduler.xml │ ├── scheduler_view.xml │ └── security │ │ └── ir.model.access.csv ├── pentaho_report_scheduler_selection_sets │ ├── __init__.py │ ├── __openerp__.py │ ├── scheduler.py │ └── scheduler_view.xml ├── pentaho_report_selection_sets │ ├── __init__.py │ ├── __openerp__.py │ ├── report_formulae.py │ ├── report_formulae_definitions.py │ ├── report_prompt.xml │ ├── report_selections.py │ ├── security │ │ ├── ir.model.access.csv │ │ └── pentaho_selection_set_security.xml │ └── wizard │ │ ├── __init__.py │ │ ├── store_selections.py │ │ └── store_selections.xml ├── pentaho_reports │ ├── .gitignore │ ├── __init__.py │ ├── __openerp__.py │ ├── core.py │ ├── core_newapi.py │ ├── data │ │ └── config_data.xml │ ├── java_oe.py │ ├── report_xml_view.xml │ ├── static │ │ └── description │ │ │ └── icon.png │ ├── ui.py │ └── wizard │ │ ├── __init__.py │ │ ├── report_prompt.py │ │ └── report_prompt.xml └── pentaho_reports_auth_crypt │ ├── __init__.py │ ├── __openerp__.py │ ├── pentaho_auth_crypt.py │ └── security │ └── ir.model.access.csv └── samples ├── pentaho_custom_data_example ├── __init__.py ├── __openerp__.py ├── reports.xml └── res_partner.py └── readme /.gitignore: -------------------------------------------------------------------------------- 1 | *.prpt 2 | *.class 3 | *.pyc 4 | *~ 5 | *.jar 6 | .pydevproject 7 | .project 8 | .settings 9 | build/ 10 | dist/ 11 | bin/ 12 | lib/ 13 | 14 | #Kde Environment 15 | *.directory -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Version 11 and Version 12 2 | 3 | Version 11 and Version 12 of the connector are available through the Odoo Apps Store. 4 | 5 | The java component and issue tracker will be maintained on: [https://github.com/WilldooIT/Pentaho-Odoo](https://github.com/WilldooIT/Pentaho-Odoo) 6 | 7 | ## Version 10 8 | 9 | Announcing First Cut v10 - Note that only SQL queries are supported at the moment - See the readme in the new repository for what state this is in. The rest will have to wait until the new year, unfortunately. 10 | 11 | [https://github.com/WilldooIT/Pentaho-Odoo](https://github.com/WilldooIT/Pentaho-Odoo) 12 | 13 | ## A Summary of Recent Changes 14 | 15 | A more detailed description of changes can be found on the [Pentaho Report for OpenERP wiki](https://github.com/WillowIT/Pentaho-reports-for-OpenERP/wiki/Significant-Changes "Pentaho Reports for OpenERP Wiki") 16 | 17 | * February 2016 - Upgrade to support Odoo version 9.0. 18 | * September 2015 - Overcome previous limitation - Now works with the auth_crypt module turned on. 19 | * August 2015 - Remove need for special duplicated "Pentaho user" - a limitation has been introduced for object based reports with password encryption turned on - work-around in pipeline. 20 | * August 2015 - Testing with Pentaho version 5.4 - updated war file on Willow website. 21 | * April 2015 - Testing with Pentaho version 5.3 - updated war file on Willow website. 22 | * October 2014 - Support for Excel 2007 format output (xlsx). 23 | * October 2014 - Testing with Pentaho version 5.2 - updated war file on Willow website. 24 | * June 2014 - Upgrade to support Odoo version 8.0. 25 | * May 2014 - Report selection sets can be nominated as default selections for users or groups. 26 | * April 2014 - Function support for default values in report selection sets, including multi value list selections. 27 | * March 2014 - Report scheduler with ability to run with selection sets. 28 | * March 2014 - Report email / message scheduler module added. 29 | * March 2014 - Selection sets creation and recalling. 30 | * March 2014 - Support for selections with multi value lists, implemented as many2manytags widget. 31 | * December 2013 - Testing and release for Pentaho version 5.0 support. 32 | * December 2013 - Support reserved variable passing to parameter queries. 33 | * November 2013 - Pentaho Report Actions better integrated to standard OpenERP Report Actions. 34 | * January 2013 - Upgrade to support OpenERP version 7.0. 35 | 36 | # Pentaho Reports for OpenERP 37 | 38 | This project provides a system that integrates OpenERP with the Pentaho reporting system. End users of OpenERP can design reports using Pentaho report designer v5.0 through v5.4, and install/access them from inside the OpenERP interface. 39 | 40 | ### Features: 41 | * Support for OpenERP 6.1, 7.0, 8.0, and 9.0. 42 | * OpenERP data can be accessed via SQL, objects, custom python procedures, or via "Pentaho Data Integration" tools. 43 | * Report parameters specified in the designer are automatically prompted for when the report is run from OpenERP. 44 | * Parameters can be generated dynamically from various data sources. 45 | 46 | _Pentaho Report designer_ is the software separate from this project that is used to design the report templates. You can download the designer [here](http://sourceforge.net/projects/pentaho/files/Report%20Designer/ "Pentaho Report Designer"). 47 | 48 | We have prepared a number of instructional videos for using this project with OpenERP [here](https://www.youtube.com/user/WillowITMedia "Willow on Youtube"). The videos provide instructions for creating reports based upon SQL and the OpenERP object data sources, and explain how to install them in OpenERP. 49 | 50 | Keep in mind that while these videos are for version 3.9 of the designer, they are still applicable. 51 | 52 | ## A Note About Versions 53 | 54 | At the time of writing, this project was working with version 3.9.1 of the Pentaho report designer, however this version is no longer supported and may stop working at any time. If you wish to use version 3.9.1, please follow the [instructions](http://pvandermpentaho.blogspot.com.au/2012/05/adding-openerp-datasource-to-pentaho.html "Pentaho 3.9.1 Plugin") to install the required plugin for the report designer. 55 | 56 | Version 5.4 is the latest version of the report designer. It comes bundled with all required plugins (data sources etc) and needs no special additional installations. 57 | 58 | ## Overview 59 | 60 | This project encompasses two separate components: 61 | 62 | ### The Java Component 63 | 64 | This is a Java web application that can be deployed in a suitable container such as [Apache Tomcat](http://tomcat.apache.org/ "Apache Tomcat"). This component does the actual rendering of the reports based upon the definitions created in the [Pentaho Report Designer](http://sourceforge.net/projects/pentaho/files/Report%20Designer/ "Pentaho Report Designer"), which is separate from this project. The Java Server communicates with OpenERP to retrieve the required data, and works with the OpenERP module (described below) to prompt the user for any required parameters, and provide selections for these parameters. 65 | 66 | ### The OpenERP Module 67 | 68 | The other component in this project is the OpenERP Module. This module allows OpenERP to communicate with the Java Server to render reports created with the Report Designer. For a more detailed explanation, look at the description of the module in OpenERP, or [here](https://github.com/WillowIT/Pentaho-reports-for-OpenERP/blob/version70/openerp_addon/pentaho_reports/__openerp__.py "__openerp__.py in Pentaho OpenERP Module"). 69 | 70 | ## Quick Start 71 | 72 | Reports can be designed and created using the [Pentaho Report Designer](http://sourceforge.net/projects/pentaho/files/Report%20Designer/ "Pentaho Report Designer") (which is software that is separate from this project). 73 | 74 | The report server needs to be installed and running. The quickest and easiest way is to download and use a pre-built .war file from [here](https://static.willdooit.net/pentaho-reports-for-openerp.war "Pentaho Report Server Packaged for Download"). This file will be rebuilt and updated on a semi-regular basis, but if the absolute latest version is required, you will have to build it yourself following the instructions [below.](#building-and-installing) 75 | 76 | The report server needs an application container such as [Apache Tomcat](http://tomcat.apache.org/ "Apache Tomcat") for it to run in. Installation and deployment on Tomcat or any other application container is beyond the scope of this document, however the Tomcat website has very detailed documentation on how to do so. 77 | 78 | The OpenERP module needs to be installed and configured, as explained [here](#the-openerp-module-1). 79 | 80 | Finally, you will need to deploy your reports. Instructions for doing this can be found in the [module description](https://github.com/WillowIT/Pentaho-reports-for-OpenERP/blob/version70/openerp_addon/pentaho_reports/__openerp__.py "__openerp__.py in Pentaho OpenERP Module") under the "Report Actions" heading. 81 | 82 | 83 | 84 | ## Building and Installing 85 | 86 | ### The Java Server 87 | To build the Java server component, a suitable [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html "Java Development Kit 7") needs to be installed. 88 | 89 | Also needed are [Apache Ant](http://ant.apache.org/ "Apache Ant") and [Apache Ivy](http://ant.apache.org/ivy/ "Apache Ivy"). Ant is the build system, and Ivy downloads all of the dependencies required. 90 | 91 | To build the project execute: 92 | 93 | $ cd /java_server 94 | $ ant 95 | 96 | Two files will be generated in the 'dist' directory. The first file, 'pentaho-reports-for-openerp.war', can be deployed using a servlet engine such as Tomcat. The second file, 'pentaho-reports-for-openerp.jar', is used when running the built in standalone test server. 97 | 98 | The standalone test server running on port 8090 can be started after a successful build using the following command: 99 | 100 | $ ant launch 101 | 102 | For production deployment, however, it is recommended that the server be hosted in an application container. Instructions on how to deploy the war file on Tomcat can be found [here](http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html#Deploying_using_the_Tomcat_Manager "Deploying Using Tomcat"). 103 | 104 | ### The OpenERP Module 105 | 106 | This module is installed like any other OpenERP module. Briefly: 107 | 108 | * Place the 'openerp_addon' folder on the filesystem, somewhere that is accessible to the OpenERP server. 109 | * Update 'openerp-server.conf' file, and include the full path to this folder on the 'addons_path' line. 110 | * Restart OpenERP and log in as a user with administrator rights. 111 | * Go to Settings -> Update Modules List and click Update. 112 | * Go to Settings -> Installed Modules, remove the 'Installed Modules' filter and search for 'pentaho'. 113 | * Install the 'Pentaho reports for OpenERP' module. 114 | 115 | After installation, the module still needs to be configured. Refer to the [module description](https://github.com/WillowIT/Pentaho-reports-for-OpenERP/blob/version70/openerp_addon/pentaho_reports/__openerp__.py "__openerp__.py in Pentaho OpenERP Module") for detailed instructions on how to do this. 116 | 117 | 118 | ## Appendices 119 | 120 | ### Integrating and Defining Reports to OpenERP 121 | 122 | The description of the OpenERP module contains an overview of creating report actions, as well as defining and using report parameters. 123 | 124 | ### Concurrency Issue When Using Email Template 125 | 126 | When generating a Pentaho report at the same time as parsing the email template, OpenERP might raise the following exception: 127 | 128 | TransactionRollbackError: could not serialize access due to concurrent update 129 | 130 | The OpenERP module 'willow_pentaho_email_patch' works around this issue. However, it is not a perfect solution to the problem and we are open to suggestions and pull requests. 131 | 132 | ### Contributors 133 | 134 | This project was developed by Willow IT, using the libraries and extensions developed by De Bortoli Wines, Australia (Pieter van der Merwe in particular) for the Pentaho reporting system. The OpenERP addon also derives from and/or is inspired by the Jasper Reports addon developed by NaN-tic. 135 | 136 | Willow IT contributions: 137 | 138 | * Deepak Seshadri - OpenERP-Pentaho server connector (Java) 139 | * Richard deMeester - frontend and core functions, automated wizard and action implementation, documentation and videos 140 | * Douglas Parker - additional integration 141 | * Jon Wilson - inspiration, testing, and whipping 142 | * Thomas Cook - documentation 143 | 144 | 145 | ## Disclaimer 146 | 147 | This project has been developed over time to meet specific requirements as we have needed to meet them. If something is wrong, or you have suggestions, please contribute via the git issues tab, or let us know at: 148 | 149 | support@willowit.com.au 150 | 151 | 152 | ## Report Library 153 | 154 | We will be endeavouring to create a library of sample and useful reports. Check at [http:www.willowit.com.au](http://www.willowit.com.au/ "WillowIT Homepage") where we will announce when and where this is available. In the meantime, if you develop any reports or templates that you would consider worth sharing, please email them through with some description or details. 155 | -------------------------------------------------------------------------------- /java_server/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /java_server/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | pentaho - 8.0 Java Server 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.wst.common.project.facet.core.nature 33 | org.eclipse.jdt.core.javanature 34 | org.eclipse.wst.jsdt.core.jsNature 35 | org.apache.ivyde.eclipse.ivynature 36 | 37 | 38 | -------------------------------------------------------------------------------- /java_server/Dockerfile.in: -------------------------------------------------------------------------------- 1 | from tomcat:8 2 | run rm -rf /usr/local/tomcat/webapps/* 3 | add @war_file@ /usr/local/tomcat/webapps/ROOT.war 4 | -------------------------------------------------------------------------------- /java_server/WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /java_server/WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | Pentaho reports for OpenERP 3 | Java XML-RPC service exposing the Pentaho reporting engine to OpenERP 4 | 5 | 6 | Pentaho boot-up checker 7 | com.willowit.application.PentahoResourceChecker 8 | 9 | 10 | 11 | Pentaho boot-up checker 12 | XmlRpcServlet 13 | 14 | 15 | 16 | com.willowit.application.PentahoResourceManager 17 | 18 | 19 | 20 | XmlRpcServlet 21 | org.apache.xmlrpc.webserver.XmlRpcServlet 22 | 1 23 | 24 | 25 | 26 | XmlRpcServlet 27 | /* 28 | 29 | 30 | -------------------------------------------------------------------------------- /java_server/build.properties: -------------------------------------------------------------------------------- 1 | project.revision=8.0.3 2 | ivy.artifact.group=com.willowit 3 | ivy.artifact.id=pentaho-reports-for-openerp 4 | impl.title=Pentaho Reports for OpenERP 5 | impl.productID=pentaho-reports-for-openerp 6 | src.dir=${basedir}/src 7 | javadoc.packagenames=com.willowit.* 8 | standalone-server-class=com.willowit.application.StandaloneReportServer 9 | 10 | junit.maxmemory=1024m 11 | junit.sysprop.user.language=en 12 | junit.sysprop.user.region=US 13 | junit.sysprop.user.timezone=UTC 14 | junit.sysprop.java.awt.headless=true 15 | junit.sysprop.file.encoding=UTF-8 16 | 17 | project.use-external-libdir=true 18 | project.use-full-dist=true 19 | ivy.default.sub-configs=internal,external 20 | ivy.use.symlinks=false 21 | 22 | pentaho-reporting.version=5.4-SNAPSHOT 23 | -------------------------------------------------------------------------------- /java_server/build.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 34 | 35 | 36 | 37 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /java_server/ivy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 35 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /java_server/ivysettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /java_server/src/com/willowit/application/PentahoResourceChecker.java: -------------------------------------------------------------------------------- 1 | package com.willowit.application; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.SQLException; 6 | import java.util.Collection; 7 | import java.util.LinkedList; 8 | 9 | import javax.servlet.Filter; 10 | import javax.servlet.FilterChain; 11 | import javax.servlet.FilterConfig; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.ServletRequest; 14 | import javax.servlet.ServletResponse; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | public class PentahoResourceChecker implements Filter { 21 | 22 | private static ThreadLocal> connections = new ThreadLocal>() { 23 | protected java.util.Collection initialValue() { 24 | return new LinkedList(); 25 | }; 26 | }; 27 | 28 | public static void registerConnection(Connection conn) { 29 | connections.get().add(conn); 30 | } 31 | 32 | private Logger log; 33 | 34 | private FilterConfig config; 35 | 36 | public void init(FilterConfig config) throws ServletException { 37 | this.config = config; 38 | this.log = LoggerFactory.getLogger(getClass()); 39 | } 40 | 41 | public void destroy() { 42 | } 43 | 44 | public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { 45 | Boolean pentaho_boot = (Boolean) config.getServletContext().getAttribute("pentaho_boot_success"); 46 | 47 | try { 48 | if(pentaho_boot != null && pentaho_boot.booleanValue()) 49 | chain.doFilter(req, resp); 50 | else 51 | ((HttpServletResponse) resp).sendError(404, "Pentaho boot failure!"); 52 | } finally { 53 | closeAllConnections(); 54 | } 55 | } 56 | 57 | private void closeAllConnections() { 58 | for (Connection conn: connections.get()) { 59 | try { 60 | if (conn.isClosed()) { 61 | continue; 62 | } 63 | log.warn("Found an open connection after request", conn); 64 | } catch (SQLException e) { 65 | log.warn("Failed to check if connection was closed", e); 66 | } 67 | try { 68 | conn.close(); 69 | } catch (SQLException e) { 70 | log.warn("Failed to close connection", e); 71 | } 72 | } 73 | connections.get().clear(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /java_server/src/com/willowit/application/PentahoResourceManager.java: -------------------------------------------------------------------------------- 1 | package com.willowit.application; 2 | 3 | import javax.servlet.ServletContextListener; 4 | import javax.servlet.ServletContextEvent; 5 | 6 | import org.apache.commons.logging.Log; 7 | import org.apache.commons.logging.LogFactory; 8 | 9 | import org.apache.commons.lang3.exception.ExceptionUtils; 10 | 11 | import com.willowit.reporting.PentahoRenderer; 12 | 13 | public class PentahoResourceManager implements ServletContextListener { 14 | private static Log logger = LogFactory.getLog(PentahoResourceManager.class); 15 | 16 | public void contextInitialized(ServletContextEvent event) { 17 | logger.info("Initialising Pentaho report renderering application."); 18 | Exception boot_exception = PentahoRenderer.bootPentaho(); 19 | 20 | if(boot_exception != null) { 21 | event.getServletContext().setAttribute("pentaho_boot_success", false); 22 | logger.error(boot_exception.getMessage()); 23 | logger.error(ExceptionUtils.getStackTrace(boot_exception)); 24 | } else 25 | event.getServletContext().setAttribute("pentaho_boot_success", true); 26 | } 27 | 28 | public void contextDestroyed(ServletContextEvent event) { 29 | logger.info("Shutting down Pentaho report renderering application."); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java_server/src/com/willowit/application/StandaloneReportServer.java: -------------------------------------------------------------------------------- 1 | package com.willowit.application; 2 | 3 | import org.apache.xmlrpc.server.XmlRpcServer; 4 | import org.apache.xmlrpc.server.PropertyHandlerMapping; 5 | import org.apache.xmlrpc.webserver.WebServer; 6 | import org.apache.commons.lang3.exception.ExceptionUtils; 7 | import org.apache.commons.logging.Log; 8 | import org.apache.commons.logging.LogFactory; 9 | 10 | import com.willowit.reporting.PentahoRenderer; 11 | 12 | public class StandaloneReportServer { 13 | private static Log logger = LogFactory.getLog(StandaloneReportServer.class); 14 | 15 | public static void main(String[] args) { 16 | //Start up Pentaho 17 | Exception boot_exception = PentahoRenderer.bootPentaho(); 18 | if(boot_exception != null) { 19 | logger.error(boot_exception.getMessage()); 20 | logger.error(ExceptionUtils.getStackTrace(boot_exception)); 21 | System.exit(1); 22 | } 23 | 24 | try { 25 | int port = 8090; 26 | 27 | if(args.length > 0) 28 | port = java.lang.Integer.parseInt(args[0]); 29 | 30 | java.net.InetAddress server_spec = java.net.Inet4Address.getByName("0.0.0.0"); 31 | 32 | logger.info("Attempting to start XML-RPC server at " + server_spec.toString() + ":" + port); 33 | WebServer server = new WebServer(port, server_spec); 34 | XmlRpcServer rpc_server = server.getXmlRpcServer(); 35 | 36 | PropertyHandlerMapping phm = new PropertyHandlerMapping(); 37 | phm.addHandler("report", PentahoRenderer.class); 38 | rpc_server.setHandlerMapping(phm); 39 | 40 | server.start(); 41 | logger.info("Started successfully"); 42 | logger.info("Accepting requests"); 43 | } catch(Exception exception) { 44 | logger.error(exception.getMessage()); 45 | logger.error(ExceptionUtils.getStackTrace(exception)); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /java_server/src/com/willowit/reporting/PentahoRenderer.java: -------------------------------------------------------------------------------- 1 | package com.willowit.reporting; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.sql.Connection; 5 | import java.sql.SQLException; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.Hashtable; 9 | 10 | import org.apache.commons.lang3.exception.ExceptionUtils; 11 | import org.apache.commons.logging.Log; 12 | import org.apache.commons.logging.LogFactory; 13 | import org.pentaho.reporting.engine.classic.core.AbstractReportDefinition; 14 | import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot; 15 | import org.pentaho.reporting.engine.classic.core.CompoundDataFactory; 16 | import org.pentaho.reporting.engine.classic.core.DataFactory; 17 | import org.pentaho.reporting.engine.classic.core.MasterReport; 18 | import org.pentaho.reporting.engine.classic.core.ReportElement; 19 | import org.pentaho.reporting.engine.classic.core.RootLevelBand; 20 | import org.pentaho.reporting.engine.classic.core.Section; 21 | import org.pentaho.reporting.engine.classic.core.SubReport; 22 | import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider; 23 | import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory; 24 | import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil; 25 | import org.pentaho.reporting.engine.classic.core.modules.output.pageable.plaintext.PlainTextReportUtil; 26 | import org.pentaho.reporting.engine.classic.core.modules.output.table.csv.CSVReportUtil; 27 | import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil; 28 | import org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.RTFReportUtil; 29 | import org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelReportUtil; 30 | import org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext; 31 | import org.pentaho.reporting.engine.classic.core.parameters.ListParameter; 32 | import org.pentaho.reporting.engine.classic.core.parameters.ParameterAttributeNames; 33 | import org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry; 34 | import org.pentaho.reporting.engine.classic.core.parameters.ParameterValues; 35 | import org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition; 36 | import org.pentaho.reporting.engine.classic.core.parameters.ReportParameterValidator; 37 | import org.pentaho.reporting.engine.classic.core.parameters.ValidationMessage; 38 | import org.pentaho.reporting.engine.classic.core.parameters.ValidationResult; 39 | import org.pentaho.reporting.engine.classic.core.util.ReportParameterValues; 40 | import org.pentaho.reporting.engine.classic.extensions.datasources.openerp.OpenERPDataFactory; 41 | import org.pentaho.reporting.libraries.fonts.LibFontBoot; 42 | import org.pentaho.reporting.libraries.resourceloader.LibLoaderBoot; 43 | import org.pentaho.reporting.libraries.resourceloader.Resource; 44 | import org.pentaho.reporting.libraries.resourceloader.ResourceManager; 45 | 46 | import com.debortoliwines.openerp.reporting.di.OpenERPFilterInfo; 47 | import com.willowit.application.PentahoResourceChecker; 48 | 49 | public class PentahoRenderer { 50 | private static Log logger = LogFactory.getLog(PentahoRenderer.class); 51 | 52 | //One common manager instance to be initialised on startup 53 | private static ResourceManager manager; 54 | 55 | //Common method 56 | public static Exception bootPentaho() { 57 | Exception exception = null; 58 | if(ClassicEngineBoot.getInstance().isBootDone() == false) { 59 | LibLoaderBoot.getInstance().start(); 60 | LibFontBoot.getInstance().start(); 61 | ClassicEngineBoot.getInstance().start(); 62 | 63 | exception = ClassicEngineBoot.getInstance().getBootFailureReason(); 64 | } 65 | 66 | return exception; 67 | } 68 | 69 | public PentahoRenderer() { 70 | if(manager == null) { 71 | manager = new ResourceManager(); 72 | manager.registerDefaults(); 73 | } 74 | } 75 | 76 | //Internal functions 77 | //DBW 78 | private void fixOpenERPDataFactoryConfiguration(OpenERPDataFactory factory, HashMap openerp_settings, HashMap parameters, Section section) { 79 | String selected_query_name = ((AbstractReportDefinition) section).getQuery(); 80 | 81 | //Fix up connection parameters 82 | if(openerp_settings != null) { 83 | String openerp_host = openerp_settings.get("host"); 84 | String openerp_port = openerp_settings.get("port"); 85 | String openerp_db = openerp_settings.get("db"); 86 | String openerp_login = openerp_settings.get("login"); 87 | String openerp_password = openerp_settings.get("password"); 88 | 89 | if(openerp_host != null) 90 | factory.getConfig().setHostName(openerp_host); 91 | if(openerp_port != null) 92 | factory.getConfig().setPortNumber(Integer.parseInt(openerp_port)); 93 | if(openerp_db != null) 94 | factory.getConfig().setDatabaseName(openerp_db); 95 | if(openerp_login != null) 96 | factory.getConfig().setUserName(openerp_login); 97 | if(openerp_password != null) 98 | factory.getConfig().setPassword(openerp_password); 99 | } 100 | 101 | //Fix up filters for the main query on the main report 102 | //Skip subreports because it should join up with specific filters to the main report query 103 | if(parameters != null && parameters.get("ids") != null && section instanceof MasterReport && factory.getQueryName().equals(selected_query_name)) { 104 | String model_path = "[" + factory.getConfig().getModelName() + "]"; 105 | boolean has_filters = false; 106 | ArrayList filters = factory.getConfig().getFilters(); 107 | 108 | for(OpenERPFilterInfo filter : filters) { 109 | if (filter.getModelPath().equals(model_path)) { 110 | has_filters = true; 111 | break; 112 | } 113 | } 114 | 115 | if(has_filters == false) 116 | filters.add(new OpenERPFilterInfo(model_path, 1, "", "id", "in", parameters.get("ids"))); 117 | } 118 | } 119 | 120 | private SQLReportDataFactory fixSQLDataFactoryConfiguration(SQLReportDataFactory factory, HashMap postgres_settings) throws Exception { 121 | SQLReportDataFactory new_factory; 122 | DriverConnectionProvider new_settings; 123 | 124 | String postgres_host = postgres_settings.get("host"); 125 | String postgres_port = postgres_settings.get("port"); 126 | String postgres_db = postgres_settings.get("db"); 127 | String postgres_login = postgres_settings.get("login"); 128 | String postgres_password = postgres_settings.get("password"); 129 | 130 | if(postgres_host == null || postgres_db == null) 131 | throw new Exception("Invalid JDBC data source settings passed: PostgreS server's hostname (or IP address) and the database name must be set if specifying custom connection settings."); 132 | 133 | if(postgres_login == null) 134 | postgres_login = factory.getUserField(); 135 | 136 | if(postgres_password == null) 137 | postgres_password = factory.getPasswordField(); 138 | 139 | if(postgres_port == null) 140 | postgres_port = "5432"; 141 | 142 | String jdbc_url = "jdbc:postgresql://" + postgres_host + ":" + postgres_port + "/" + postgres_db; 143 | 144 | new_settings = new DriverConnectionProvider() { 145 | private static final long serialVersionUID = 1L; 146 | 147 | @Override 148 | public Connection createConnection(String user, String password) 149 | throws SQLException { 150 | Connection conn = super.createConnection(user, password); 151 | PentahoResourceChecker.registerConnection(conn); 152 | return conn; 153 | } 154 | }; 155 | new_settings.setDriver("org.postgresql.Driver"); 156 | new_settings.setUrl(jdbc_url); 157 | new_settings.setProperty("user", postgres_login); 158 | new_settings.setProperty("password", postgres_password); 159 | 160 | //The following may not be necessary since we set the JDBC URL 161 | new_settings.setProperty("::pentaho-reporting::name", "Custom PostgreS datasource"); 162 | new_settings.setProperty("::pentaho-reporting::hostname", postgres_host); 163 | new_settings.setProperty("::pentaho-reporting::port", postgres_port); 164 | new_settings.setProperty("::pentaho-reporting::database-name", postgres_db); 165 | new_settings.setProperty("::pentaho-reporting::database-type", "POSTGRESQL"); 166 | 167 | new_factory = new SQLReportDataFactory(new_settings); 168 | new_factory.setUserField(postgres_login); 169 | new_factory.setPasswordField(postgres_password); 170 | new_factory.setGlobalScriptLanguage(factory.getGlobalScriptLanguage()); 171 | new_factory.setGlobalScript(factory.getGlobalScript()); 172 | 173 | for(String one_query_name : factory.getQueryNames()) 174 | new_factory.setQuery(one_query_name, factory.getQuery(one_query_name), factory.getScriptingLanguage(one_query_name), factory.getScript(one_query_name)); 175 | 176 | return new_factory; 177 | } 178 | 179 | private void fixConfiguration(Section section, HashMap openerp_settings, HashMap postgres_settings, HashMap parameters) throws Exception { 180 | //If one of the datasources is an OpenERP datasource, reset the connection to the passed parameters 181 | if(section instanceof AbstractReportDefinition) { 182 | 183 | CompoundDataFactory factories = (CompoundDataFactory) ((AbstractReportDefinition) section).getDataFactory(); 184 | for(int j = 0; j < factories.size(); j++) { 185 | DataFactory data_factory = factories.getReference(j); 186 | if(data_factory instanceof OpenERPDataFactory) 187 | fixOpenERPDataFactoryConfiguration((OpenERPDataFactory) data_factory, openerp_settings, parameters, section); 188 | else if(data_factory instanceof SQLReportDataFactory && postgres_settings != null) { 189 | String[] postgres_setting_names = {"host", "port", "db", "login", "password"}; 190 | 191 | boolean custom_settings = false; 192 | for(String custom_setting_name : postgres_setting_names) 193 | custom_settings |= (postgres_settings.get(custom_setting_name) != null); 194 | 195 | if(custom_settings) 196 | factories.set(j, fixSQLDataFactoryConfiguration((SQLReportDataFactory) data_factory, postgres_settings)); 197 | } 198 | } 199 | } 200 | 201 | //Go through all children and fix up their datasources too 202 | for(int i = 0; i < section.getElementCount(); i++) { 203 | ReportElement e = section.getElement(i); 204 | 205 | if(e instanceof Section) 206 | fixConfiguration((Section) e, openerp_settings, postgres_settings, parameters); 207 | 208 | // Fix subreports 209 | if (e instanceof RootLevelBand){ 210 | for (SubReport sub : ((RootLevelBand) e).getSubReports()) 211 | fixConfiguration((Section) sub, openerp_settings, postgres_settings, parameters); 212 | } 213 | } 214 | } 215 | 216 | //Checks the validity of parameters values set earlier 217 | //Not used at the moment 218 | private void checkParameters(MasterReport report) throws Exception { 219 | DefaultParameterContext param_context = new DefaultParameterContext(report); 220 | ReportParameterDefinition param_def = report.getParameterDefinition(); 221 | ReportParameterValidator validator = param_def.getValidator(); 222 | ValidationResult validation_result = validator.validate(new ValidationResult(), param_def, param_context); 223 | 224 | for(int i = 0; i < param_def.getParameterCount(); i++) 225 | for(ValidationMessage msg : validation_result.getErrors(param_def.getParameterDefinition(i).getName())) 226 | logger.info("Parameter Error: " + msg.getMessage()); 227 | } 228 | 229 | //Helper functions 230 | private HashMap getParametersTypes(MasterReport report) throws Exception { 231 | ReportParameterDefinition param_def = report.getParameterDefinition(); 232 | ParameterDefinitionEntry[] param_def_entries = param_def.getParameterDefinitions(); 233 | 234 | HashMap name_to_type = new HashMap(); 235 | 236 | for(ParameterDefinitionEntry param_def_entry : param_def_entries) 237 | name_to_type.put(param_def_entry.getName(), param_def_entry.getValueType()); 238 | 239 | return name_to_type; 240 | } 241 | 242 | private void typeCastAndStore(ReportParameterValues target, String parameter_type, String parameter_name, Object parameter_value) { 243 | if(parameter_type.equals("java.lang.Long")) 244 | target.put(parameter_name, new Long(((Integer) parameter_value))); 245 | else if(parameter_type.equals("java.lang.Short")) 246 | target.put(parameter_name, ((Integer) parameter_value).shortValue()); 247 | else if(parameter_type.equals("java.math.BigInteger")) 248 | target.put(parameter_name, java.math.BigInteger.valueOf(((Integer) parameter_value))); 249 | else if(parameter_type.equals("java.lang.Float")) 250 | target.put(parameter_name, ((Double) parameter_value).floatValue()); 251 | else if(parameter_type.equals("java.math.BigDecimal")) 252 | target.put(parameter_name, java.math.BigDecimal.valueOf(((Double) parameter_value))); 253 | else if(parameter_type.equals("java.sql.Date")) 254 | target.put(parameter_name, new java.sql.Date(((java.util.Date) parameter_value).getTime())); 255 | else if(parameter_type.equals("java.sql.Time")) 256 | target.put(parameter_name, new java.sql.Time(((java.util.Date) parameter_value).getTime())); 257 | else if(parameter_type.equals("java.sql.Timestamp")) 258 | target.put(parameter_name, new java.sql.Timestamp(((java.util.Date) parameter_value).getTime())); 259 | else 260 | target.put(parameter_name, parameter_value); 261 | } 262 | 263 | private byte[] renderReport(MasterReport report, String output_type) throws Exception { 264 | //Create the report output stream 265 | ByteArrayOutputStream report_bin_out = new ByteArrayOutputStream(); 266 | 267 | if(output_type.equals("pdf")) 268 | PdfReportUtil.createPDF(report, report_bin_out); 269 | else if(output_type.equals("xls")) 270 | ExcelReportUtil.createXLS(report, report_bin_out); 271 | else if(output_type.equals("xlsx")) 272 | ExcelReportUtil.createXLSX(report, report_bin_out); 273 | else if(output_type.equals("csv")) 274 | CSVReportUtil.createCSV(report, report_bin_out, null); 275 | else if(output_type.equals("rtf")) 276 | RTFReportUtil.createRTF(report, report_bin_out); 277 | else if(output_type.equals("html")) 278 | HtmlReportUtil.createStreamHTML(report, report_bin_out); 279 | else if(output_type.equals("txt")) 280 | PlainTextReportUtil.createPlainText(report, report_bin_out); 281 | 282 | return report_bin_out.toByteArray(); 283 | } 284 | 285 | //Exported methods 286 | @SuppressWarnings("unchecked") 287 | public ArrayList> getParameterInfo(Hashtable args) throws Exception { 288 | ArrayList> ret_val = new ArrayList>(); 289 | 290 | //FIXME: redundant code 291 | HashMap parameters = new HashMap(); 292 | HashMap> connection_settings = new HashMap>(); 293 | HashMap openerp_settings = new HashMap(); 294 | HashMap postgres_settings = new HashMap(); 295 | 296 | try { 297 | byte[] prpt_file_content = (byte[]) args.get("prpt_file_content"); 298 | 299 | if(prpt_file_content == null) 300 | throw new Exception("No report content sent!"); 301 | 302 | //FIXME: redundant code 303 | connection_settings = (HashMap>) args.get("connection_settings"); 304 | parameters = (HashMap) args.get("report_parameters"); 305 | openerp_settings = (HashMap) connection_settings.get("openerp"); 306 | postgres_settings = (HashMap) connection_settings.get("postgres"); 307 | 308 | Resource res = manager.createDirectly(prpt_file_content, MasterReport.class); 309 | MasterReport report = (MasterReport) res.getResource(); 310 | 311 | fixConfiguration(report, openerp_settings, postgres_settings, parameters); 312 | 313 | if (parameters != null){ 314 | HashMap parameters_types = getParametersTypes(report); 315 | // Set parameters available 316 | ReportParameterValues values = report.getParameterValues(); 317 | for(String parameter_name : parameters.keySet()) { 318 | Object parameter_value = parameters.get(parameter_name); 319 | 320 | if(parameters_types.get(parameter_name) != null){ 321 | typeCastAndStore(values, ((Class) parameters_types.get(parameter_name)).getName(), parameter_name, parameter_value); 322 | } 323 | } 324 | } 325 | 326 | //New stuff 327 | ReportParameterDefinition param_def = report.getParameterDefinition(); 328 | ParameterDefinitionEntry[] param_def_entries = param_def.getParameterDefinitions(); 329 | DefaultParameterContext param_context = new DefaultParameterContext(report); 330 | for(ParameterDefinitionEntry param_def_entry : param_def_entries) { 331 | HashMap one_param_info = new HashMap(); 332 | HashMap core_namespace_attributes = new HashMap(); 333 | 334 | one_param_info.put("name", param_def_entry.getName()); 335 | one_param_info.put("value_type", param_def_entry.getValueType().getName()); 336 | one_param_info.put("is_mandatory", param_def_entry.isMandatory()); 337 | 338 | Object default_value = param_def_entry.getDefaultValue(param_context); 339 | if(default_value != null) { 340 | String param_def_entry_type = param_def_entry.getValueType().getName(); 341 | 342 | if(param_def_entry_type.equals("java.lang.Long")) 343 | default_value = ((Long) default_value).intValue(); 344 | else if(param_def_entry_type.equals("java.lang.Short")) 345 | default_value = ((java.lang.Short) default_value).intValue(); 346 | else if(param_def_entry_type.equals("java.math.BigInteger")) 347 | default_value = ((java.math.BigInteger) default_value).intValue(); 348 | else if(param_def_entry_type.equals("java.lang.Number")) 349 | default_value = ((Number) default_value).doubleValue(); 350 | else if(param_def_entry_type.equals("java.lang.Float")) 351 | default_value = ((Float) default_value).doubleValue(); 352 | else if(param_def_entry_type.equals("java.math.BigDecimal")) 353 | default_value = ((java.math.BigDecimal) default_value).doubleValue(); 354 | 355 | one_param_info.put("default_value", default_value); 356 | } 357 | one_param_info.put("attributes", core_namespace_attributes); 358 | 359 | String[] param_attr_names = param_def_entry.getParameterAttributeNames(ParameterAttributeNames.Core.NAMESPACE); 360 | for(String param_attr_name : param_attr_names) { 361 | String param_attr = param_def_entry.getParameterAttribute(ParameterAttributeNames.Core.NAMESPACE, param_attr_name, param_context); 362 | core_namespace_attributes.put(param_attr_name, param_attr); 363 | logger.debug("Attribute: " + param_attr_name + " = " + param_attr); 364 | } 365 | 366 | if(param_def_entry instanceof ListParameter) { 367 | ParameterValues param_vals = ((ListParameter) param_def_entry).getValues(param_context); 368 | int num_options = param_vals.getRowCount(); 369 | ArrayList> selection_options = new ArrayList>(num_options); 370 | 371 | for(int i = 0; i < num_options; i++) { 372 | ArrayList one_option = new ArrayList(); 373 | 374 | one_option.add(param_vals.getKeyValue(i)); 375 | one_option.add(param_vals.getTextValue(i)); 376 | 377 | selection_options.add(one_option); 378 | logger.debug("Selection option: {" + param_vals.getKeyValue(i) + ": " + param_vals.getTextValue(i) + "}"); 379 | } 380 | 381 | one_param_info.put("selection_options", selection_options); 382 | } 383 | 384 | ret_val.add(one_param_info); 385 | } 386 | 387 | return ret_val; 388 | } catch(Exception exception) { 389 | logger.error(exception.getMessage()); 390 | logger.error(ExceptionUtils.getStackTrace(exception)); 391 | 392 | throw exception; 393 | } 394 | } 395 | 396 | @SuppressWarnings("unchecked") 397 | public byte[] execute(Hashtable args) throws Exception { 398 | byte[] prpt_file_content = null; 399 | String output_type = null; 400 | 401 | HashMap parameters = new HashMap(); 402 | HashMap> connection_settings = new HashMap>(); 403 | HashMap openerp_settings = new HashMap(); 404 | HashMap postgres_settings = new HashMap(); 405 | 406 | logger.debug(args); 407 | 408 | try { 409 | prpt_file_content = (byte[]) args.get("prpt_file_content"); 410 | output_type = (String) args.get("output_type"); 411 | 412 | if(prpt_file_content == null) 413 | throw new Exception("No report content sent!"); 414 | 415 | if(output_type == null) 416 | output_type = "pdf"; 417 | 418 | connection_settings = (HashMap>) args.get("connection_settings"); 419 | parameters = (HashMap) args.get("report_parameters"); 420 | openerp_settings = (HashMap) connection_settings.get("openerp"); 421 | postgres_settings = (HashMap) connection_settings.get("postgres"); 422 | 423 | //Load the report (we may be overriding Pentaho's caching mechanisms by doing this 424 | Resource res = manager.createDirectly(prpt_file_content, MasterReport.class); 425 | MasterReport report = (MasterReport) res.getResource(); 426 | HashMap parameters_types = getParametersTypes(report); 427 | 428 | //Fix up data sources specified by parameters passed in 429 | fixConfiguration(report, openerp_settings, postgres_settings, parameters); 430 | 431 | //Pass through other parameters 432 | ReportParameterValues values = report.getParameterValues(); 433 | for(String parameter_name : parameters.keySet()) { 434 | Object parameter_value = parameters.get(parameter_name); 435 | 436 | if(parameters_types.get(parameter_name) != null) 437 | typeCastAndStore(values, ((Class) parameters_types.get(parameter_name)).getName(), parameter_name, parameter_value); 438 | } 439 | 440 | return renderReport(report, output_type); 441 | } catch(Exception exception) { 442 | logger.error(exception.getMessage()); 443 | logger.error(ExceptionUtils.getStackTrace(exception)); 444 | 445 | throw exception; 446 | } 447 | } 448 | } 449 | -------------------------------------------------------------------------------- /java_server/src/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.appender.C=org.apache.log4j.ConsoleAppender 2 | log4j.appender.C.layout=org.apache.log4j.PatternLayout 3 | log4j.appender.C.layout.ConversionPattern=%p %t %c - %m%n 4 | log4j.rootLogger=info, C 5 | -------------------------------------------------------------------------------- /java_server/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties: -------------------------------------------------------------------------------- 1 | report=com.willowit.reporting.PentahoRenderer 2 | -------------------------------------------------------------------------------- /odoo_addon/pentaho_report_scheduler/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import scheduler 4 | -------------------------------------------------------------------------------- /odoo_addon/pentaho_report_scheduler/__openerp__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | { 3 | 'name': 'Report Scheduler', 4 | "version": "0.1", 5 | "author": "WillowIT Pty Ltd", 6 | 'website': 'http://www.willowit.com.au', 7 | "category": "Reporting subsystems", 8 | 'summary':'Report Scheduler', 9 | 'images': [], 10 | 'depends': ['base'], 11 | 'description': """ 12 | Report Email / Message Scheduler 13 | ================================ 14 | This module provides a simple scheduler running daily reports. The reports may not accept any parameters. 15 | 16 | The module "Report Scheduler Selection Sets" (pentaho_report_scheduler_selection_sets) module extends this module 17 | and allows Pentaho reports to be scheduled with pre-entered selections. 18 | 19 | Chosen reports can be either emailed to users or sent to their OpenERP message box as a notification, or both. 20 | 21 | A new option is added to the menus: 22 | * **Settings / Technical / Actions / Scheduler / Report Scheduler** 23 | 24 | From here, a report schedule group can be defined. The description will be included in the message or email body. 25 | 26 | Once defined, the schedule group needs to be associated with a standard OpenERP schedule task. (An example 27 | schedule task is created by this module, and is titled **Report Email Scheduler**). On the **Technical Data** tab, 28 | the name of the schedule group needs to be included in the action argument. 29 | 30 | e.g. *('Report Group 1',)* 31 | 32 | Note the **comma** after the argument **IS** required. 33 | """, 34 | 'data': [ 35 | 'scheduler.xml', 36 | 'scheduler_view.xml', 37 | 'security/ir.model.access.csv', 38 | ], 39 | 'demo': [], 40 | 'test': [], 41 | 'installable': True, 42 | 'auto_install': False, 43 | 'application': False, 44 | } 45 | -------------------------------------------------------------------------------- /odoo_addon/pentaho_report_scheduler/scheduler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from openerp import models, fields, api, _ 4 | import datetime 5 | from openerp import netsvc 6 | import json 7 | import openerp 8 | 9 | from openerp.addons.pentaho_reports.java_oe import parameter_resolve_column_name 10 | 11 | class ReportScheduler(models.Model): 12 | _name = "ir.actions.report.scheduler" 13 | _description = "Report Scheduler" 14 | 15 | name = fields.Char(string='Name', size=64, required=True) 16 | description = fields.Text(string='Description') 17 | action_type = fields.Selection([('email', 'Send Email'), ('notification', 'Send to User Notifications'), ('both', 'Notification and Email')], string='Type', required=True) 18 | line_ids = fields.One2many('ir.actions.report.scheduler.line', 'scheduler_id', string='List of Reports', help="Enter a list of reports to run.") 19 | user_list = fields.Many2many('res.users', 'rep_sched_user_rel', 'sched_id', 'user_id', string='List of Users', help="Enter a list of users to receive the reports.") 20 | 21 | def dt_to_local(self, dt): 22 | """Convert a UTC date/time to local. 23 | 24 | @param dt: A date/time with a UTC time. 25 | @param context: This must contain the user's local timezone 26 | as context['tz']. 27 | """ 28 | # Returns 'NONE' if user has no tz defined or tz not passed 29 | # in the context. 30 | return fields.Datetime.context_timestamp(self, dt) 31 | 32 | @api.multi 33 | def _send_reports(self, reports): 34 | self.ensure_one() 35 | run_on = datetime.datetime.now() 36 | run_on_local = self.dt_to_local(run_on) 37 | if not run_on_local: 38 | run_on_local = run_on 39 | 40 | report_summary = """Run on:%s 41 | 42 | %s""" % (run_on_local.strftime('%d-%b-%Y at %H:%M:%S'), self.description or '') 43 | 44 | # attachments={} 45 | # for rpt_name, content, type in reports: 46 | # attach_fname = "%s-%s.%s" % (rpt_name, run_on_local.strftime('%Y-%m-%d-%H-%M-%S'), type) 47 | # attachments[attach_fname] = content 48 | 49 | attachments = self.env['ir.attachment'] 50 | for rpt_name, content, type in reports: 51 | attachments += attachments.create({'datas': content.encode('base64'), 52 | 'name': rpt_name, 53 | 'datas_fname': '%s.%s' % (rpt_name, type), 54 | }) 55 | 56 | if self.action_type in ('email', 'both'): 57 | email_addresses = [x.email for x in self.user_list if x.email] 58 | if email_addresses: 59 | msg = self.env['mail.mail'].create({'subject' : self.name, 60 | 'email_from' : self.env.user.email, 61 | 'email_to' : ','.join(email_addresses), 62 | 'attachment_ids' : [(6, 0, attachments.ids)], 63 | 'body_html' : report_summary, 64 | }) 65 | msg.send() 66 | 67 | if self.action_type in ('notification', 'both'): 68 | receiver_ids = [x.partner_id.id for x in self.user_list] 69 | if receiver_ids: 70 | self.env['mail.message'].create({'subject': self.name, 71 | 'type': "notification", 72 | 'partner_ids': [(6, 0, receiver_ids)], 73 | 'attachment_ids': [(6, 0, attachments.ids)], 74 | 'body': report_summary, 75 | }) 76 | 77 | @api.model 78 | def _check_overriding_values(self, line, values_so_far): 79 | return {} 80 | 81 | @api.model 82 | def _report_variables(self, line): 83 | result = {} 84 | if line.report_type == 'pentaho': 85 | # attempt to fill the prompt wizard as if we had gone in to it from a menu and then run. 86 | promptwizard_obj = self.env['ir.actions.report.promptwizard'] 87 | 88 | # default_get creates a dictionary of wizard default values 89 | values = promptwizard_obj.default_get_external(line.report_id) 90 | # this hook is provided to allow for selection set values, which are not necessarily installed 91 | values.update(self._check_overriding_values(line, values)) 92 | 93 | if values: 94 | # now convert virtual screen values from prompt wizard to values which can be passed to the report action 95 | result = {'output_type': values.get('output_type'), 96 | 'variables': {}} 97 | parameters = json.loads(values.get('parameters_dictionary')) 98 | for index in range(0, len(parameters)): 99 | result['variables'][parameters[index]['variable']] = promptwizard_obj.decode_wizard_value(parameters, index, values[parameter_resolve_column_name(parameters, index)]) 100 | 101 | return result 102 | 103 | @api.multi 104 | def _run_all(self): 105 | for sched in self: 106 | if sched.line_ids or sched.user_list: 107 | report_output = [] 108 | for line in sched.line_ids: 109 | report = line.report_id 110 | datas = {'model': sched._name, 111 | } 112 | datas.update(sched._report_variables(line)) 113 | if report.report_type in ['qweb-html', 'qweb-pdf']: 114 | content, type = self.pool['report'].get_pdf(self.env.cr, self.env.uid, [], report.report_name, context=self.env.context), 'pdf' 115 | else: 116 | content, type = openerp.report.render_report(self.env.cr, self.env.uid, [], report.report_name, datas, self.env.context) 117 | report_output.append((report.name, content, type)) 118 | if report_output: 119 | sched._send_reports(report_output) 120 | 121 | @api.multi 122 | def button_run_now(self): 123 | self._run_all() 124 | 125 | @api.model 126 | def run_report_email_scheduler(self, scheduled_name=''): 127 | self.search([('name', '=', scheduled_name)])._run_all() 128 | 129 | 130 | class ReportSchedulerLines(models.Model): 131 | _name = "ir.actions.report.scheduler.line" 132 | _description = "Report Scheduler Lines" 133 | 134 | scheduler_id = fields.Many2one('ir.actions.report.scheduler', string='Scheduler') 135 | report_id = fields.Many2one('ir.actions.report.xml', string='Report', required=True, ondelete='cascade') 136 | sequence = fields.Integer('Sequence') 137 | report_type = fields.Selection(string='Report Type', related='report_id.report_type', readonly=True) 138 | model = fields.Char(string='Object', related='report_id.model', readonly=True) 139 | type = fields.Char(string='Action Type', related='report_id.type', readonly=True) 140 | 141 | _order='sequence' 142 | -------------------------------------------------------------------------------- /odoo_addon/pentaho_report_scheduler/scheduler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Report Email Scheduler 7 | 8 | 9 | 1 10 | days 11 | 2000-01-01 00:00:00 12 | -1 13 | 14 | ir.actions.report.scheduler 15 | run_report_email_scheduler 16 | (['']) 17 | 10 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /odoo_addon/pentaho_report_scheduler/scheduler_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | view.sched.form 6 | ir.actions.report.scheduler 7 | 8 |
9 |
10 |
12 | 13 |
14 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
38 |
39 |
40 |
41 | 42 | 43 | view.sched.tree 44 | ir.actions.report.scheduler 45 | 46 | 47 | 48 |