Retrieve Packing Slip's Items information From Delivery Note Print Format


I want to create a Report (Print Format) from Delivery Notes that shows all the Packing Slips and their Items in one report, I’m close to do it but after some essay & error, I got stock pulling the Packing Slips Items Info because they always return blank. Here is where I’m going so far:

{%set slips = frappe.get_list("Packing Slip", filters={ 'delivery_note':}) %}
{{ slips }} // This returns [{'name': u'PS0000013'}, {'name': u'PS0000012'}, {'name': u'PS0000011'}]
{% set slip = frappe.get_doc("Packing Slip", slips[0]['name']) %}
{{ slip.__dict__ }}  // This returns {  'name': u'PS0000013',.... } //PS info
{{ slip.get('items') }} //This returns []
{{ slip.items }} //This returns []

I’m sure the PS I’m using has items associated.

I made this code from different topics, the most helpful was #10064ttps://

I think I’m missing something but can’t figure it out, can anyone help me?

I’m using ERPNext V6

Do you get any values back in slips?

Hi Kanchan
Looks like he is not getting any results, can you please advise why it would not return anything back?

Yes @Kanchan,

In slips are the three Slips ID, if not, would gave me OutOfRangeError or something,

Do you see any other flaw?


Edit: The main post was edited adding more information on variable’s information.

After this try:
{{slip.(some other PS field)}}

See what does it return.

Hi @RafaAguilar

Try below code

{%- for row in slip.items -%}
{%- endfor -%}


Hi @rohit_w,

That worked as you said, can I ask you two doubts?:

  • is Items some kind of @property ?
  • Why use dash in {%- ... -%} ?

Thanks a lot pal, and thanks a lot to @KanchanChauhan too!

That is jinja template. - is used to remove whitespaces

The method items() returns a list of dict’s (key, value) tuple pairs

Yes, but items it’s not being called as a method, it’s called as a property for the missing parenthesis, or isn’t?

Hello @rohit_w is there an updated code for this in v11 because i cant get the code above to work. I followed exact code but it doesnt work :frowning: Please help. Thanks!

Hi @rohit_w @KanchanChauhan
I want to get specific Sales Invoice and loop the items under it.

I used this code

{% var test = frappe.get_doc("Sales Invoice", "SI-2019-00001") %}

But nothing happens and I think variable test has the value of null. Any idea please?

I used var instead of set because set returns an error