How to access the value of another doctype in the print format.
Which value you want to fetch in print format?
frappe.db.get_value('Customer', doc.customer, 'credit_days')
this will fetch credit days in print format.
In Address template if i want to print all the items in the item master. How can i do that?
Sorry, I doesn’t understand.
In address template there is no item.
ya in address there is no item.
I want to fetch list of Item from Item Doctype
Do you have any reference of item in Address Template.
What is your use-case?
No dont have any reference.
Give me a sample to fetch from another doctype with reference
here doc.customer is reference.
{{ frappe.db.get_value(‘Customer’, doc.customer, ‘customer_type’) }}
I have given this in address doctype
Im getting error as
Traceback (innermost last):
File “/home/vaijeyanthi/frappe-bench/apps/frappe/frappe/app.py”, line 51, in application
response = frappe.handler.handle()
File “/home/vaijeyanthi/frappe-bench/apps/frappe/frappe/handler.py”, line 69, in handle
execute_cmd(cmd)
File “/home/vaijeyanthi/frappe-bench/apps/frappe/frappe/handler.py”, line 92, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/vaijeyanthi/frappe-bench/apps/frappe/frappe/init.py”, line 751, in call
return fn(*args, **newargs)
File “/home/vaijeyanthi/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 107, in get_html
html = template.render(args, filters={“len”: len})
File “/home/vaijeyanthi/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 969, in render
return self.environment.handle_exception(exc_info, True)
File “/home/vaijeyanthi/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File “”, line 1, in template
TemplateSyntaxError: unexpected char u’&’ at 103
please remove curly brackets,
frappe.db.get_value('Customer', doc.customer, 'customer_type')
Can you share your print format?
if i remove curley brackets. it just printing
frappe.db.get_value('Customer', doc.customer, 'customer_type')
the same
can you share your print format?
Ohh, you are using print format builder.
Please check my images
Steps:
- in print format builder UI, Drag Custom HTML into location you want to print.
- Click on Edit Html
- write this code {{ frappe.db.get_value(‘Customer’, doc.customer, ‘customer_type’) }}
- refresh your print format. This will show customer details as Individual
Ok … Thankyou… Its working
@kolate_sambhaji: Hi Sambhaji,
I have address as a linked field in a doctype. All entries made while filling this DocType are storedas entries under “Address” DocType. When I want to print our the entire address in the print, how do I reference the particular address that is linked to this document? I hope this makes sense.
@Rohan_J You need to fetch address using Address template, then you can print it.
e.g.1 purchase common.js
//on selecting address in shipping_address full address is copied into shipping_address_display
shipping_address: function(){
var me = this;
erpnext.utils.get_address_display(this.frm, "shipping_address",
"shipping_address_display", is_your_company_address=true)
},
e.g.2
cur_frm.cscript.buyer = function() {
erpnext.utils.get_address_display(this.frm, "buyer", "buyer_address");
};
//buyer is address field, and on select of buyer, I am fetching full address in buyer_address
Hi @kolate_sambhaji,
“get_address_display” is not working in v8, can you suggest changed method for v8?
Thanks
Edit: found the solution
Replace: erpnext.utils.get_address_display
with : frappe.geo.doctype.address.address.get_address_display
Hi @kolate_sambhaji
I am trying to create custom reports
any reference where i can start learning
what all language should i know
thanks
hemanth