Fetch "Advance Paid"


I need to fetch the sum of advance paid at Sales Order…

At Delivery Note…

But obviously it’s not working. I tried fetching the value right in the custom field at Delivery Note…

And using custom scripts like:

frappe.ui.form.on("Delivery Note", "onload", function(frm) {
	cur_frm.add_fetch("from_quotation", "advance_paid", "sales_order_advance_paid");

Using “customer_name”, “grand_total”, and others… but it just don’t populate.

Any ideas will be much appreciated!

@Francisco_Buendia, Trying with set field type Read Only of Sales Order Advance Paid field on Delivery Note form.

Hi @priya_s

I have tried that way…

And also tried…

Note: Tried also changing the name “sales_order_advance_paid” of custom field at Delivery Note, for just “advance_paid” as it is at Sales Order.

And no… it doesn’t fetch, pull, any data.

Also tried with other scripts like:

frappe.ui.form.on("Delivery Note", "onload", function(frm) {
                frappe.db.get_value("Sales Order", docname, "advance_paid");
                cur_frm.set_value("advance_paid", doc.advance_paid); 

No results.

And tried too with…

frappe.ui.form.on("Delivery Note", "onload", function(frm) {
                    'method': 'frappe.client.get_value',
                    'args': {
                        'doctype': 'Sales Order',
                        'fieldname': 'advance_paid',
                          'filters': {'name': 'sales_order'}
                       callback: function(r){
                       } ;

Found this last script at http://sbkolate.blogspot.mx/2016/03/erpnext-get-value-from-another-doc-in.html. But I’m certainly applying bad, because it cause the following error:

SyntaxError: Unexpected token ;
    at Class.setup (https://colinadeldescanso.erpnext.com/assets/js/form.min.js:2624:17)
    at _f.Frm.setup (https://colinadeldescanso.erpnext.com/assets/js/form.min.js:172:22)
    at _f.Frm.refresh (https://colinadeldescanso.erpnext.com/assets/js/form.min.js:439:9)
    at Class.load (https://colinadeldescanso.erpnext.com/assets/js/form.min.js:87:33)
    at https://colinadeldescanso.erpnext.com/assets/js/form.min.js:82:7
    at Object.callback (https://colinadeldescanso.erpnext.com/assets/js/desk.min.js:6635:6)
    at Object.callback [as success_callback] (https://colinadeldescanso.erpnext.com/assets/js/desk.min.js:1228:16)
    at _ (https://colinadeldescanso.erpnext.com/assets/js/desk.min.js:1252:34)
    at Object. (https://colinadeldescanso.erpnext.com/assets/js/desk.min.js:1349:5)
    at i (https://colinadeldescanso.erpnext.com/assets/frappe/js/lib/jquery/jquery.min.js:2:27151)

Thank to Saurabh Palande’s support, found that the problem is at Doctype.

If the field it’s checked “No Copy”, data won’t be fetched or populated automatically.

I’m not able to make any changes at DocType since it’s an account paid at Frappe, will wait for ERPNext support. I hope this information would be helpful for others :wink:

Thanks @rmehta and ERPNext for your effort and support!