I want to fetch the address and contact of the supplier here, how can I do that? I am using the Purchase Order to make this print format:
<div class="supplier">
<p>{{ doc.supplier_name }}</p>
<p>{{ supplier_address }}</p>
<p>{{ supplier_contact }}</p>
</div>
Meet
2
@Hamza3351 U can try this code
Supplier Address
<p>{{doc.address_display }}</p>
Billing Address
<p>{{doc.billing_address_display }}</p>
Shipping Address
<p>{{doc.shipping_address_display }}</p>
Contact Details
<p>{{ doc.contact_display or ""}}</p>
Mobile No
<p>{{ doc.contact_mobile or "" }}</p>
Email
<p>{{ doc.contact_email or "" }}</p>
1 Like
How do I get the contact no?
Mobile No
<p>{{ doc.contact_mobile or "" }}</p>
1 Like
It’s not working, Here you can see I have address and contact details filled but it doesn’t shows in the print format:
Nothing in the print format:
Supplier Address
<p>{{doc.address_display }}</p>
Contact Details
<p>{{ doc.contact_display}}</p>
1 Like
I have tried this but no good as you can see my previous reply…
@Hamza3351 as you see this is my test and it worked well ??!
1 Like
you can fetch with this
Example:
frappe.db.get_value("Contact", {"customer": doc.customer}, "mobile_no")
1 Like
I have tried this code but I can fetch the static data only:
<div class="supplier">
{% set address = frappe.db.get_value('Address', '786 MALIK GOODS-Billing', ['address_line1']) %}
{% set contact = frappe.db.get_value('Contact', '786 MALIK GOODS-786 MALIK GOODS', ['phone']) %}
<p>{{ doc.supplier_name }}</p>
<p>{{ address }}</p>
<p>{{ contact }}</p>
</div>
Error in print format on line 27: (1054, “Unknown column ‘customer’ in ‘where clause’”)
You are using print builder, try it in a custom format if it works
Try this
<div class="supplier">
{% set address = frappe.db.get_value("Address", {"address_title": doc.supplier}, "address_line1") %}
<p>{{ doc.supplier_name }}</p>
<p>{{ address }}</p>
</div>
I have tested
1 Like
This one works fine , thanks
If you want to fetch all mobile number from the table
you can fetch same like this
1 Like
do I fetch it like this:
{% set contact = frappe.db.get_value("Contact", {"contact_title": doc.supplier}, "phone") %}
In summary, this is how we can fetch both, we just need to find a link between the name of the field and the doctype which it is linked to:
<div class="supplier">
{% set address = frappe.db.get_value("Address", {"address_title": doc.supplier_name}, "address_line1") %}
{% set contact = frappe.db.get_value("Contact", {"first_name": doc.supplier_name}, "phone") %}
<p>{{ doc.supplier_name }}</p>
<p>{{ address }}</p>
<p>{{ contact }}</p>
</div>