Using "Report Card" code to generate Certificate gives error

Hi

I am still trying to get ERPNext to generate a certificate for me.

I had a look at the code that is generating the “Report card” and I hacked / duplicated that
together with its own HTML file to yield a resonable looking certificate. But I did that by hijacking the “Report Card” button top right. I now want to give that proper function back
to that button and create another button that says : “Print Certificate” I did that by adding
a “set_secondary_action” to the refresh: function code in
student_report_generating_tool.js
Now, when I go to Student Report Generating Tool in Education, the doc does not render
properly. It halts with the SAVE button visible.

No error in the erro_log.

Could someone please provide some guidance ?

I am using
ERPNext: v12.28.0 (version-12)
Frappe Framework: v12.25.0 (version-12

    refresh: function(frm) {
            frm.disable_save();
            frm.page.clear_indicator();
            frm.page.set_primary_action(__('Print Report Card'), () => {
                    let url = "/api/method/erpnext.education.doctype.student_report_generation_tool.student_report_generation_tool.preview_report_card";
                    open_url_post(url, {"doc": frm.doc}, true);
            });
            frm.page.set_secondary_action(__('Print Certificate'), () => {
                    let url1 = "/api/method/erpnext.education.doctype.student_report_generation_tool.student_report_generation_tool.preview_certificate";
                    open_url_post(url1, {"doc": frm.doc), true);
            });
    },

Update…

It is working. Not that this is my work because I really hacked the existing code to get this \working so its not really good enough for a pull request… but I am happy to share what I did
incase there is someone that wants to use this …

I have added my voice to a feature request for something like this …# 29455. Hopefully it will
be in an upcoming release.

Here is what I did …
This is on
ERPNext: v12.28.0 (version-12)
Frappe Framework: v12.25.0 (version-12)

I added another button to the Student Report Generation Tool page…

I modified student_report_generation_tool.js as follows…

    refresh: function(frm) {
            frm.disable_save();
            frm.page.clear_indicator();
            frm.page.set_primary_action(__('Print Report Card'), () => {
                    let url = "/api/method/erpnext.education.doctype.student_report_generation_tool.student_report_generation_tool.preview_report_card";
                    open_url_post(url, {"doc": frm.doc}, true);
            });
            frm.page.set_secondary_action(__('Print Certificate'), () => {
                    let url1 = "/api/method/erpnext.education.doctype.student_report_generation_tool.student_report_generation_tool.preview_certificate";
                    open_url_post(url1, {"doc": frm.doc}, true);
            });
    },

I added another “def” in student_report_generation_tool.py …
def preview_certificate(doc):

And that whole function/ method is just a copy of
def preview_report_card, except the reference HTML doc

I then created student_certificate_generation_tool.html which was the HTML template
for my certificate

Here is what the new Student Report Generation Tool page looks like …

And this is what my certificate looks like . Apologies for the black blocks but I felt it proper
to remove the company logo which was involved.

+

1 Like