I want to add shipping address + contact to my Purchase Order. I have it all figured out (I think) with custom fields and print forms, but I cannot get the full value/data of the Custom Field to show in the final printed PO.
step1 - I have made two Custom Fields, both DocType Links for Contact and Address.
step2 - Then, in my Purchase Order, I am able to select from available Addresses and Contacts to propogate the fields – so far so good.
step3 - Then, I made a Print Format that has both these Custom Fields added.
step4 - Finally, when I print, it shows the two Custom Fields, but it only shows the title/heading of those fields, NOT the full data. How do I print the data that is held within the fields I selected?
This is the only roadblock to me actually using ERPNext for real. Thanks!
@rmehta - I’m using the VM downloaded from the website.
In the first picture - http://i.imgur.com/Mm2qnhc.jpg - it is showing the Address Title on the final PDF output … I want it to show all the data contained within that address record. The address record has city, street, etc. and I want that to show on the PDF, not just the title of the address record. Does that make sense?
Show it how? I don’t see anything in the Print Format Builder to get the address data. The custom link field I created shows up in the Print Format Builder but I don’t see any way to get the address data over from the custom field … sorry, confused
I refreshed the PO form back to defaults and tried again. I customized the form, made a single field (Link to Address). When I add the field to the print form, it still only shows the title “XYZ-Shipping” and not the actual address. I can’t make it work
I’m trying to do the same thing and I think I’ve found a way. It is more complicated, but it is somewhat working for me.
The short answer is that you need to add custom scripts that will populate other fields:
Create your custom fields that are links for contact and address.
Create additional custom fields for the Address Line 1, Address Line 2, City/Town, State, Postal, etc. The data type is Data, and make them hidden.
Create a custom field that is a Small Text that will hold the full address (“supplier_address”)
Create a custom script for the Purchase Order form and use the following lines of code:
frappe.ui.form.on(“Purchase Order”, “onload”,function(frm)
{
var text = frm.doc.shipping_address_line1 + ‘\n’;
if(frm.doc.shipping_address_line2 != ‘’)
{
text +=frm.doc.shipping_address_line2 + ‘\n’;
}
if(frm.doc.shipping_address_city != ‘’)
{
text +=frm.doc.shipping_address_city + ‘\n’;
}
if(frm.doc.shipping_address_state != ‘’)
{
text +=frm.doc.shipping_address_state + ‘\n’;
}
if(frm.doc.shipping_address_country != ‘’)
{
text +=frm.doc.shipping_address_country + ‘\n’;
}
if(frm.doc.shipping_address_postal!= ‘’)
{
text +=frm.doc.shipping_address_postal+ ‘\n’;
}
frm.set_value(“shipping_address”,text);
});
The explanation is as follows: I use the add fetch to grab all the address details and put them in the hidden fields.
Then, on any sheet update, I grab all those fields and fill them into the shipping address text.
This is a really ugly way of doing it, but I’m just getting started with the coding and am not familiar with all the functions.
@Ben_Cornwell_Mott - thanks for chiming in. I ended up doing very similar things to solve my problem. I did steps 1 and 2 and then similar custom scripts like you did in step 4. I handled step 3 and the building of the final address in a new print format using custom HTML so that it shows when I generate the PO PDF. Basically, we did the same thing but through equally roundabout means. This was really annoying to figure out at first, but I learned a lot along the way. My custom HTML:
Thanks for the tip! I think I was able to get it working really well. It took quite a bit of searching through the documentation, but now this solves all the problems. To explain: when the supplier_address is updated, the frappe.call funciton is used, which gets the address information and allows it to be formatted. I think this is a much more elegant solution than what I was doing before.