Help: Print format template & Frappe Obj

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>



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-forum+un…@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.
You can't use frappe.db.get_value to get a child table

Use

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




On 06-Sep-2014, at 1:48 pm, Nonnatee Kanjana <no...@ps-groups.com> wrote:

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>




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-forum+un…@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.



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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/DEEA6C06-405B-4C2A-B7F9-B0687744085E%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.

“Warning: This Print Format is in old style and cannot be generated via the API.”…Why am i getting this warning ?

New print formats must be generated on server side.