Help: Print format template & Frappe Obj.

199 views
Skip to first unread message

Nonnatee Kanjana

unread,
Sep 6, 2014, 4:18:29 AM9/6/14
to erpnext-dev...@googlegroups.com
Hi,

Could someone give an example of frappe.db.get_value usage please. I keep running into error or null obj when trying to call /use any function of the Frappe Obj. -_-‘

my code:

 <div id="doc_items">
       
<table class="tbl">
           
<tbody>
               
<tr>
                   
<td class="tbl_header" style="width: 3%;">#</td>
                   
<td class="tbl_header" style="width: 57%;">{{ _("Description") }}</td>
                   
<td class="tbl_header" style="width: 5%; text-align: right;"> {{ _("Qty") }}
                   
</td>
                   
<td class="tbl_header" style="width: 5%;">{{ _("UOM") }}</td>
                   
<td class="tbl_header" style="width: 15%; text-align: right;">{{ _("Basic Rate") }}</td>
                   
<td class="tbl_header" style="width: 15%; text-align: right;">{{ _("Amount") }}</td>
               
</tr>
           
   
                {%- for row in doc.entries %}
                    {%- if row.against_invoice and row.credit -%}
                       
<tr>
                           
<td colspan="6"> Invoice No. {{ row.get("against_invoice") }} | {# x length of item #} item{# if x > 0 #}s{# endif #} |{{ row.get_formatted("credit",doc) }} </td>
                       
</tr>
                        {% for item in frappe.db.get_value("Sales Invoice", row.against_invoice, ["entries"]) -%}
                       
<tr>
                           
<td style="width: 3%;">  X </td>
                           
<td width="50%" align="left" style="vertical-align:top;">
                                {{ item.item_name }}
                                {% if item.description != item.item_name -%}
                               
<br>
                               
<i><small style="color:gray;"> {{  item.description  }} </small></i>
                                {%- endif -%}


                           
</td>
                           
<td style="width: 5%; text-align: right;"> {{ item.qty }} </td>
                           
<td style="width: 5%;"> {{ item.uom or item.stock_uom }} </td>
                           
<td style="width: 15%; text-align: right;">{{ item.get_formatted("rate", doc) }} </td>
                           
<td style="width: 15%; text-align: right;">{{ item.get_formatted("amount", doc) }}</td>
                       
</tr>
                        {% endfor %}
                    {% endif -%}
                   
                    {%- if row.against_invoice and row.debit -%}
                        {# ...... #}
                    {% endif -%}
                {% endfor -%}
           
</tbody>
       
</table>
   
</div>

Rushabh Mehta

unread,
Sep 8, 2014, 12:53:53 AM9/8/14
to erpnext-dev...@googlegroups.com
You can't use frappe.db.get_value to get a child table

Use

frappe.get_doc("Sales Invoice", row.against_invoice).entries




--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/a77aeae8-b743-463f-83bf-f163fed1d501%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages