Print Format to get the fields of another doctype

I want to create a print format on the doctype name "Delivery Note " . In this i want to get the columns form the doctype named “Quality Inspection” in the jinja format .how to get the columns because their is no link between this doctype .

Please help me to get this requirement.

You can use frappe.get_doc and frappe.db.get_value inside a Jinja2 template. Check this repo for lots of examples:

If In Item master, Quality inspection required before Delivery check box is checked then when you create a delivery note then before submit a delivery note you have to create a quality inspection and that quality inspection no is set in delivery note items table. you can easily get quality inspection using

{% for row in doc.items %}
{{ row.quality_inspection}}
{% endfor %}

@Kiranmai
Fetching Data from ‘Quality Inspection’ Doctype :

{% set gl = frappe.get_list('Quality Inspection',filters={'status':('in',('.....'))}, fields=["......"], group_by="......") %}

This line creates a variable ql in Jinja template. It’s used to store the list of records fetched from the ‘Quality Inspection’ doctype.

Iterating Over the Fetched Data :slight_smile:

{% for item in ql %}
    <tr>
        {% for row in item %}
            <td>{{ row.fieldname }}</td>
            <td>{{ row.fieldname }}</td>
        {% endfor %}
    </tr>
{% endfor %}

This loop iterates over each record in the list ql .

where and how do we copy and paste this code ?

@Abdullah_A_Ansari

In print format.

If you have same requirement as mentioned in this topic, then you can use it.
If not, you can share your doubts,someone who knows the solutions will give reply to you.