This is the HTML code, how can I set the company name and address inside the letter head HTML. Is it get the value from doctype?
@anon67314007 You have to create logo with company details or you can add static company details using html
Hi @anon67314007,
If you want to add the address with dynamically way then please check it.
{% set links = frappe.get_all('Dynamic Link', filters={'link_doctype': 'Company', 'link_name': doc.company, 'parenttype': 'Address'}, fields=['parent']) %}
{% if links %}
{% set address = frappe.db.get_value('Address', links[0].parent, ['address_line1', 'address_line2', 'city', 'state', 'pincode', 'country', 'email_id', 'phone'], as_dict=True) %}
{{ address.address_line1 }}<br>
{% if address.address_line2 %}{{ address.address_line2 }}<br>{% endif %}
{{ address.city }}<br>
{{ address.state }} - {{ address.pincode }}<br>
{{ address.country }}<br>
{% if address.email_id %}Email: {{ address.email_id }}<br>{% endif %}
{% if address.phone %}Phone: {{ address.phone }}{% endif %}
{% endif %}
I hope this helps!
Where we have to place this code?
I was trying to use custom script but not working
@anon67314007 if you have fix this issue, please let me know how you did it>
Place that code in print format in which you want.
I want to use it inside the letter head, so that it can affect in reports and invoices when selecting the letterhead>
The letterhead does not accept this syntax {{ address.phone }}
You can create a banner image for the company details like logo name adress contact and use as letter head
I don’t want static details like image, or pure HTML, I want it to be dynamically fetched based on the company details
it is dynamic for each company set multiple banners so when user select the company they can also select the banner for letterhead
then you can fetch the company details in that document and fetch company details in other fields and hide those field then fetch in print format when you change the company it will automatically change in the format
{% set links = frappe.get_all('Dynamic Link', filters={'link_doctype': 'Company', 'link_name': doc.company, 'parenttype': 'Address'}, fields=['parent']) %}
{% if links %}
{% set address = frappe.db.get_value('Address', links[0].parent, ['address_line1', 'address_line2', 'city', 'state', 'pincode', 'country', 'email_id', 'phone'], as_dict=True) %}
{{ address.address_line1 }}<br>
{% if address.address_line2 %}{{ address.address_line2 }}<br>{% endif %}
{{ address.city }}<br>
{{ address.state }} - {{ address.pincode }}<br>
{{ address.country }}<br>
{% if address.email_id %}Email: {{ address.email_id }}<br>{% endif %}
{% if address.phone %}Phone: {{ address.phone }}{% endif %}
{% endif %}
This code is not working inside Header HTML, neither Header Script of the Letterhead,
/app/letter-head
Is there any work around needs to be done?
@NCP
This code is not working inside Header HTML, neither Header Script of the Letterhead,
/app/letter-head
Is there any work around needs to be done?
@NCP
@Jeel Have you fix it?
@a7medalyousofi @NCP
This code is successfully working for me inside the header HTML and footer HTML of Letterhead doctype.
My exact code for footer is:
<br><div class="footie">
{% if doc.company %}
{% set links = frappe.get_all('Dynamic Link', filters={'link_doctype': 'Company', 'link_name': doc.company, 'parenttype': 'Address'}, fields=['parent']) %}
{% set website = frappe.db.get_value("Company",doc.company,"website") %}
{% set email = frappe.db.get_value("Company",doc.company,"email") %}
<table width="100%">
<tbody><tr>
<td class="left-align" border="0px" width="30%">
<b>{% if doc.company %}{{ doc.company }}{% endif %}</b>
{% if links %}
{% set address = frappe.db.get_value('Address', links[0].parent, ['address_line1', 'address_line2', 'city', 'state', 'pincode', 'country', 'email_id', 'phone'], as_dict=True) %}
<br>{{ address.address_line1 }}
<br>{% if address.address_line2 %}{{ address.address_line2 }}{% endif %}
<br>{{ address.city }}, {{ address.state }} - {{ address.pincode }}, {{ address.country }}
<br>{{ website }}
{% endif %}
{% endif %}
</td>
<td class="left-align" border="0px" width="30%">
</td>
<td class="right-align" border="0px" width="40%">
<b>Subject to Vadodara Jurisdiction</b>
<br>This document is electronically signed via ERP Software. It does not require a physical signature. {% if doc.company %}To verify its validity, email on {{ email }}{% endif %}
</td>
</tr>
</tbody></table>
</div>
While Header format I set in the particular print format of a doctype as it works for me best:
{% set logo_for_printing = frappe.db.get_value("Company",doc.company,"logo_for_printing") %}
<div class="print-heading">
<table width=100% border-collapse=collapse>
<tr>
<td class="left-align" border=0px padding=0px>
<img src="{{ logo_for_printing }}" style="object-fit: scale-down" width="75" height="75" padding=0px>
</td>
<td class="right-align" border=0px padding=0px>
<h2><b>
<div>{{ doc.select_print_heading if doc.select_print_heading else doc.doctype }}</div>
</b></h2>
{{ doc.name }}<br>
</td>
</tr>
</table>
</div>
thanks, i think they have already fix it in the last weeks, before 2 months it was not working
This letterhead is not working with the General Ledger Report, how to fix it to work with General Ledger Report?

