Unable to use frappe.get_list in custom print format

Hi all,

I’m unable to get delivery note records against sales invoice number, one sales invoice can have multiple delivery note. how to do that. I’m stuck on it.

Example code:
{%- set dn_details = frappe.get_list(“Delivery Note”, fields=[“grant_total”], filters:{“sales_invoice_number”: “SINV-00001”, “docstatus”: 1, “status”: “Completed”}) -%}

noting returned. however I have two delivery notes

I tried it in my end and looks like it is working properly.

And look at the results:

Good luck!

Ps: Make sure your Delivery Notes are Submitted and have the Status marked Completed.

2 Likes

Hi yefritavarez,
Thanks for your help, I have checked my documents and looks like they are fine but my concern is to sum all grand totals of delivery note against sales invoice. Let me show you my whole code may be I have some left bugs.

{%- set dn_grand_total = 0 -%}
{%- set dn_details = frappe.get_list(“Delivery Note”, fields=[“grant_total”], filters:{“sales_invoice_number”: “SINV-00001”, “docstatus”: 1, “status”: “Completed”}) -%}
{% for row in dn_details %}
{%- set dn_grand_total = dn_grand_total + row.grand_total -%}
{% endfor %}

{{ dn_grand_total }}
// always print 0

Yes, that makes sense as it is not possible to do that in Jinja. You can refer to this documentation if you wish to find why:
Jinja Assignments

One thing you can surely do is to have a hidden field in the doctype, then do the math in that field and finally show that field with its value.

Thanks for this post. I was able to solve a problem I was stuck on for hours after referring to it.

You’re welcome… I’m glad that it helped!