Hi ,
I need to modify the final results reports templates " senaite.impress:Default.pt" where I can find it ?
Hi @sami , result reports templates that come by default with SENAITE can be found here:
However, better create your own add-on instead of modifying the base code. In such case, you can easily add your own reports by creating your own reports folder and register it in a configure.zcml file as an static resources directory:
<plone:static
directory="reports"
type="senaite.impress.reports"
name="MyAddon"/>
Thanks @xispa … I am new to plone (but 15y of programming) …
My need is to remove the footer part of the generated Default.pt. So I assume all what I need is to copy the standard and modify it a pit.
Q1. Where to find the standard default.pt? Where in senaite.impress ?
Now, after locating it … what I need to do is
1. Create an add-on for MyPackage
2. Create directory called “reports”
3. past on it the “Default.pt” and change on it and call it “MyNewDefault.pt”
Q2. How to link it… is it going to be automatically shows as one of the dropdown options at impress tool screen(not sure what you call it) ?
Q3. Also do I need add others xml tags in configure.zcml like here
Appreciate your time.
Yes, your new report template will be displayed automatically in the dropdown options list at impress tool
Hi Sir, I read through the link given. But I am unsure where should I locate the configure.zcml
file and where should I place the the .pt
report template that I made. It will be great if you can give me some guide on that. Thank you.
Hi there, @sami have you manage to apply/link your custom report to the LIMS? Do you mind to share a step-by-step guideline on that? Thank you.
No… I still could not figure it out. I have did the change to Default.pt it self but still …the Default report still show the old content
@xispa hi Jordi… Do I need to do any thing else to make the Default.pt get refreshed… I have corrupted it just to see what effects…but still showing the old Deafault.pt in the system and still render good?
Hi all, sorry for the thread necromancy - I’ve made use of this thread and am having some success.
I’ve created my own “add-on”, ie a custom reports directory containing some of my own reports, which is showing correctly in Senaite/Analysis Reports screen. I added the stanza for my addon to the same place as the senaite.impress.reports
add-on was declared:
senaitelims/eggs/cp27mu/senaite.impress-2.5.0-py2.7.egg/senaite/impress/configure.zcml
Unfortunately, modifying this file means I’m changing the base code. What is the recommended location for me to create a configure.zcml
file without affecting the base code?
I’m running Senaite via docker-compose, it requires a docker-compose stop/start to recompile/take the changes
Some bumbling notes. I’m using the docker-compose containers/config for Senaite v2.5.0
Update the impress configure.zcml
with your addon details
/home/senaite/senaitelims/eggs/cp27mu/senaite.impress-2.5.0-py2.7.egg/senaite/impress# diff -Nrup configure.zcml.orig configure.zcml
--- configure.zcml.orig 2025-01-30 00:42:33.660859141 +0000
+++ configure.zcml 2025-01-29 05:35:09.758003591 +0000
@@ -164,6 +164,13 @@
type="senaite.impress.reports"
/>
+ <!-- Report resource directory -->
+ <plone:static
+ directory="templates/my_reports"
+ type="senaite.impress.reports"
+ name="MyReports"
+ />
+
<!-- Generic Setup *INSTALL* Profile -->
<genericsetup:registerProfile
name="default"
Create the directory you defined in the add-on stanza (templates/my_reports
):
mkdir /home/senaite/senaitelims/eggs/cp27mu/senaite.impress-2.5.0-py2.7.egg/senaite/impress/my_reports
Copy the template you want to use as your starting point into that directory and start modifying it.
Working from the MultiDefault.pt
template, it references a whole lot of “sub-templates”, the specific section I wanted to change was to add “Sample Point” to the summary fields - so I looked for the summary section:
<tal:report>
...
<!-- REPORT SUMMARY -->
<tal:t replace="structure python:view.render_summary(context, **options)" />
...
</tal:report>
After a bunch of greppingn through code, this render_summary()
function pulls from another template:
/home/senaite/senaitelims/eggs/cp27mu/senaite.impress-2.5.0-py2.7.egg/senaite/impress/analysisrequest/templates/summary.pt
Rather than try to modify the summary.pt
to add the extra field, I commented out/replaced the summary template stanza wholesale in my custom report file with the contents of summary.pt
, and then added my “Sample Point” field in there:
--- MultiDefault.pt 2025-01-29 05:40:06.595173711 +0000
+++ MyCustomMultiDefault.pt 2025-01-29 05:22:16.907116455 +0000
@@ -19,8 +19,112 @@
<tal:t replace="structure python:view.render_alerts(context, **options)" />
<!-- REPORT SUMMARY -->
+ <!--
<tal:t replace="structure python:view.render_summary(context, **options)" />
+ -->
+<tal:t define="collection view/collection;
+ model view/model;
+ batch model/Batch;
+ client model/Client;
+ reporter python:view.current_user;
+ specification model/Specification;
+ publication_specification model/PublicationSpecification;
+ spec python:publication_specification or specification;"
+ i18n:domain="senaite.impress">
+
+ <div class="row section-summary no-gutters">
+ <div class="w-100">
+
+ <!-- Barcode -->
+ <div class="text-center float-right barcode-container">
+ <div class="barcode"
+ data-code="code128"
+ data-showHRI="true"
+ data-barHeight="15"
+ data-addQuietZone="true"
+ tal:attributes="data-id model/getId">
+ </div>
+ </div>
+
+ <h1 i18n:translate="">Summary</h1>
+
+ <table class="table table-sm table-condensed">
+ <tr>
+ <td style="width:20%" class="label" i18n:translate="">Sample ID</td>
+ <td>
+ <a tal:content="model/getId"
+ tal:attributes="href model/absolute_url;">
+ </a>
+ </td>
+ </tr>
+ <tr tal:condition="batch">
+ <td class="label" i18n:translate="">Batch ID</td>
+ <td>
+ <a tal:content="batch/id"
+ tal:attributes="href batch/absolute_url">
+ </a>
+ </td>
+ </tr>
+ <tr tal:condition="batch">
+ <td class="label" i18n:translate="">Client Batch ID</td>
+ <td tal:content="batch/ClientBatchID"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Client</td>
+ <td>
+ <a tal:attributes="href client/absolute_url"
+ tal:content="client/Name"></a>
+ </td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Client SID</td>
+ <td tal:content="model/ClientSampleID"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Sample Type</td>
+ <td tal:content="model/SampleType/title"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Sample Point</td>
+ <td tal:content="model/SamplePointTitle">placeholder</td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Specification</td>
+ <td tal:content="spec/contextual_title|nothing"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Date Received</td>
+ <td tal:content="python:view.to_localized_time(model.DateReceived)"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Date Verified</td>
+ <td tal:content="python:view.to_localized_time(model.getDateVerified())"></td>
+ </tr>
+ <tr>
+ <td class="label" i18n:translate="">Date Published</td>
+ <td tal:content="python:view.to_localized_time(view.timestamp)"></td>
+ </tr>
+ <tr tal:condition="reporter">
+ <td class="label" i18n:translate="">Published by</td>
+ <td>
+ <span tal:content="reporter/fullname|reporter/username"/>
+ <tal:email tal:condition="reporter/email|nothing"
+ tal:define="email reporter/email">
+ (<a tal:content="email"
+ tal:attributes="href string:mailto:${email}"></a>)
+ </tal:email>
+ </td>
+ </tr>
+ <tr tal:condition="python: batch and batch.BatchLabels">
+ <td class="label" i18n:translate="">Batch Labels</td>
+ <td tal:content="structure python:', '.join(batch.BatchLabels)"></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+</tal:t>
<!-- REPORT RESULTS -->
<tal:t replace="structure python:view.render_results(context, **options)" />
Hope that helps
Thanks man for the ubdate… appreciate it…
I wish if somebody have a complete blog in how to add a field all the way to the report section.
Without the assumption that we know plone.
I have tried to figure how plone work so that I know how to customise/ change senaite… but plone it self has a high learning curve and little English resource.( check youtube for plone for example)…
Very powerful software… but we can not put other people business at risk because we don’t know how to fix this if broken!!
I think I’ve found the answer -
You include it from some other ZCML file
ref: python - How to make zope load my ZCML? - Stack Overflow
If this is correct, then the base code requires modification at some level to include my add-on