ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Add new field to report item tables column selection list


#1

Hello All,

I would like to add a new field into the delivery note report items (table) column selection list, I tried to search from source code but cannot found the way to do , please guide me, thanks


#2

YOu customize it yet?


#3

Actually i need to show the custom po no and customer item no. now i may try to use jinja + frappe.db.sql to achieve them…but still no luck now , error should be comes from frappe.db.sql… but don’t know why…

below is my report script :

<table class="table table-bordered table-condensed">
  <thead>
        <tr>
            <th style="width:3%">#</th>
	    <th>{{_("Order Date")}}</th>
	    <th>{{_("P.O. No")}}</th>
	    <th>{{_("FSID")}}</th>
	    <th>{{_("Vendor Product#")}}</th>
            <th style="width:40%" >{{ _("Item")}}</th>
            <th style="width:10%;text-align:right">{{_("Quantity")}}</th>
        </tr>
    </thead>
    <tbody>
        <tr>{%- for row in doc.items-%}
            <td>{{ row.idx }}</td>
	    <td>{{frappe.db.get_value("Sales Order",row.against_sales_order,"po_date")}}</td>
	    <td>{{frappe.db.get_value("Sales Order",row.against_sales_order,"po_no")}}</td>
	    <td><div>{{frappe.db.sql("""select ref_code from `tabItem Customer Detail` where parentfield = 'customer_items' and parent = '971091100001' and customer_name = 'EclipseCust'""")}} </div></td>
            <td ><div>{{ row.item_code}}</div></td>
            <td ><div>{{ row.item_name}}</div></td>
            <td class="text-right"><div class="value">
		<span class="pull-left">{{row.qty}}</span><small>{{row.uom}}</small></div></td>
        </tr>{%- endfor -%}
    </tbody>
</table>

here is the error message :
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja.py”, line 77, in render_template
return get_jenv().from_string(template).render(context)
File “/home/frappe/frappe-bench/env/lib/python3.5/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/home/frappe/frappe-bench/env/lib/python3.5/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/home/frappe/frappe-bench/env/lib/python3.5/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File "


#4

We had also this requirement in the past. We added 2 new fields to the required doctype (Delivery Note in this case) and we made them linked to the items. So we just use these new fields in the printer.


#5

Finally I used frappe.db.get_value , here is the code :

{{frappe.db.get_value(“Item Customer Detail”,{“parentfield”:“customer_items”,“parent”:row.item_code,“customer_name”:doc.customer},“ref_code”)}}