ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

How to add sales order and delivery note serial number in sales invoice

Hello everyone!

I want to include linked sales order and delivery note serial number in sales invoice print format. Is there any way to achieve that? thanks in advance :wink:

image

<table width=90% height=30% border=1>
<tr>
   <td width=50% rowspan=3>
       <strong>{{ doc.company or "" }}</strong><br>
       {{ frappe.db.get_value("Company", doc.company, "registration_details") or "" }}
   </td>
   <td width=25%>
       Invoice No.<br>
       <b>{{ doc.name }}</b>
   </td>
   <td width=25%>
       Dated<br>
   <b>{{ frappe.utils.formatdate(doc.posting_date) }}</b>
  </td>
</tr>
<tr>
<td width=25%>
Delivery Note <br>
  <b>{{frappe.db.get_value("Delivery Note", {"name": doc.items[0].delivery_note}, "name")}}
   </b>
   </td>
   <td width=25%>
      Delivery Date. <br>
      <b>{{frappe.db.get_value("Delivery Note", {"name": doc.items[0].delivery_note}, "posting_date")}}
     </b>
   </td>
   </tr>
   <tr>
   <td width=25%>
       Supplier's Ref.<br>
   <b>&nbsp;</b>
   </td>
   <td width=25%>
       Other Reference(s)<br>
   <b>&nbsp;</b>
   </td>
</tr>
<tr>
   <td width=50% rowspan=4> 
    Customer<br>
    <strong>{{ doc.customer_name or "" }}</strong><br>
 {{ doc.address_display or "" }}
     </td>
    <td width=25%>
       Buyer's Order No.<br>
       <b>{{frappe.db.get_value("Sales Order", {"name": doc.items[0].sales_order}, "name")}}.  
       </b>
   <b>&nbsp;</b>
   </td>
   <td width=25%>
       Dated<br>
        <b>{{frappe.db.get_value("Sales Order", {"name": doc.items[0].sales_order}, "transaction_date")}}</b>
   <b>&nbsp;</b>
   </td>