Adapt a built-in Report
A question was posted to the Discourse forum wondering if there were tips somewhere for copying an internal Gramps report to a make an experimental add-on?
It seems like more people would be intrigued with the possibilities of tweaking reports without the risk of breaking a feature. Particularly one that they use often enough that tweaking it seemed like a good idea.
Making a duplicate add-on sidesteps putting the original at risk. However, there are differences between built-ins and 3rd party add-ons. It seemed like that might require at least converting the library paths and making a new
.gpr.py registration file. What else?
In a private message, GaryG privately replied and sent a few copies of reports generated that address the question.
In the sample cases, Gary had taken the Detailed Ancestor and Detailed Descendant stock reports and added the ability to include *all* images for everyone. The Detailed individual report had that functionality, but the ancestor/descendant did not.
The important changes
- Change the Class names to be unique. Each report has 2 classes - one for the code and one for the report. In my cases, I added a trailing ‘i’.
- Change the name of the report styles. This is necessary if you are using books, not absolutely required if not. For the Descendant report I changed the style prefix from DDR to DDRI, for instance. I didn’t change the Ancestor report.
- Update the
.gpr.pyregistration file to point to the correct file and correct classes.
Attaching are 2 samples with the old (names ending with report.py) and the new code (names ending with reporti.py) as well as the revised
.gpr.py files. The old code may have changed since I wrote the new code quite a while ago - so every diff may not be important.