Print issue {{ frappe.db.get_value("Customer", doc.customer, "tax_id") }}

i using
TRN#: {{ frappe.db.get_value(“Customer”, doc.customer, “tax_id”) }}
and
Customer#:{{ frappe.db.get_value(“Customer”, doc.customer, “customer_code”) }}

They are displaying in erpnext like


But when i output pdf, these two fields display “None”

How to make the value can be displayed in pdf.

My system is:
ERPNext: v11.1.44 (master)
Frappe Framework: v11.1.39 (master)

1 Like

Try this …
edit the site_config.json, and add the static IP address of your local server.

eg.
“host_name”: “http://192.168.1.111
then do a bench restart

thank you for your reply.
Now in my site_config.json
“host_name”: “https://erp.manchemical.com”,

so now if i change to static IP,like http://192.168.1.111

Is there any other problem happen?

i did two trials:
“host_name”: “http://localhost”,
and
“host_name”: “http://192.168.1.111”,

the same problem, in erpnext, ok, but display “none” in pdf.

You need to adjust the IP address to match your requirements - I just used 192.168.1.111 as an example

i think i using http://localhost is the same function as static ip, right?
Now localhost is not working for solving this issue.

If you have an entry in the /etc/hosts file that matches the IP of your machine, then it should also work, so like this (but change the xxx to match the actual IP)

127.0.0.1 localhost
192.168.1.xxx erp.manchemical.com

now in my /etc/hosts:

127.0.1.1 manchemical.com manchemical
127.0.0.1 localhost

So i need to add 192.168.1.xxx erp.manchemical.com, or change
127.0.1.1 manchemical.com manchemical?

Now I add 167.xx.68.6 erp.manchemical.com:
So it looks like:

127.0.1.1 manchemical.com manchemical
127.0.0.1 localhost
167.xx.68.6 erp.manchemical.com

167.xx.68.6 is my server ip.

but still display “none” in pdf.

just now even i change
“host_name”: “https://167.xx.68.6” in site_config.json
and bench restart.

Still “none” in pdf.

sorry, i am fresh in erpnext, and appreciated to help me, please help me to solve this issue!

Did you create a report builder version, or is this a Jinja2 output?

i dont know, i installed original erpnext.

How is this even related?

Check if the customer has that data. I will provide a sample below with even additional custom fields:
{%- if frappe.db.get_value(“Customer”, doc.customer, “customer_type”) == “Individual” -%}
{%- if frappe.db.get_value(“Customer”, doc.customer, “tax_id”) -%}{{ frappe.db.get_value(“Customer”, doc.customer, “tax_id”) }}{%- endif -%}
{%- else -%}
{{ frappe.db.get_value(“Customer”, doc.customer, “tax_office”) }}/{{ frappe.db.get_value(“Customer”, doc.customer, “tax_id”) }}{%- endif -%}

1 Like

can try to help if you can post the whole code

i tried your code today, still problem.
please check the code here:

<!---Start:Header--->

<div id="header">
<table style="width:100%;margin:0;padding:0; max-width:100%;font-family:verdana; font-size:10px;color:#666">
<tr>
<td colspan="6" style="width:50%;padding-left:10px">TO:</td><td colspan="4" style="width:50%;padding-left:10px">Customer Reference</td>
</tr>
<tr>

<td colspan="6" rowspan="6" style="width:50%;padding-left:10px;font-style:italic;color:#333">{{ doc.customer_name or '' }}<br />{{ doc. address_display or '' }}<br />TRN#:{{ frappe.db.get_value("Customer", doc.customer, "tax_id") }}
 </td>
<td style="padding-left:10px;width:16%">Customer#:</td>
<td align="right" style="width:11%; font-style:italic;color:#333">
{{ frappe.db.get_value("Customer", doc.customer, "customer_code") }}</td>
<td style="padding-left:10px;width:13%">Invoice#:</td>
<td align="right" style="width:10%;font-style:italic;color:#333"><span class="serials">{{ doc.name }}</span></td>
</tr>
<tr>
<td style="padding-left:10px;width:16%">Currency:</td>
<td align="right" style="width:11%;font-style:italic;color:#333">{{ doc. currency or ''}}</td>
<td style="padding-left:10px;width:13%">IncoTerm:</td>
<td align="right" style="width:10%;font-style:italic;color:#333">{{ doc. incoterm or ''}}-{{ doc. incoterm_fill or ''}}</td>
</tr>
<tr>
<td style="padding-left:10px;width:16%">Transport:</td>
<td align="right" style="width:11%;font-style:italic;color:#333">{{ doc. transport or ''}}</td>
<td style="padding-left:10px;width:13%">Lead Time:</td>
<td align="right" style="width:10%;font-style:italic;color:#333">{{ doc. lead_time or '' }}</td>
</tr>
<tr>
<td style="padding-left:10px;width:16%">Prepared By:</td>
 {% if doc.owner -%}
    {% set u = frappe.get_doc("User", doc.owner) %}    {% endif %}       
<td align="right" style="width:11%;font-style:italic;color:#333">{{ u.first_name or ''}}</td>

<td style="padding-left:10px;width:13%">Credit:</td>
<td align="right" style="width:10%;font-style:italic;color:#333">{{ doc.get_formatted("credit_days") or ''}} Days</td>
</tr>
<tr>
 {% if doc.company %}      
    {% set u = frappe.get_doc("Company", doc.company) %}           
{% endif %}
  <td style="padding-left:10px;width:16%">Company:</td>
  <td colspan="3" align="right" style="width:11%;font-style:italic;color:#333"><span style="margin-right: 10px">{{ doc.company or '' }}</span> {{ u.other_company_name or '' }}</td>
  </tr>
<tr>

<td style="padding-left:10px;width:16%">License#: </td>

<td align="right" style="width:11%;font-style:italic;color:#333">{{ u. license_no or '' }}</td>
<td style="padding-left:10px;width:13%">TRN#:</td>
<td align="right" style="width:10%;font-style:italic;color:#333">{{ u. trn_no or '' }}</td>
</tr>
<tr>
{% if doc.contact_person %}      
    {% set u = frappe.get_doc("Contact", doc.contact_person) %}           
{% endif %}
<td style="width:5%;padding-left:20px">Tel:</td>
<td colspan="2" style="width:20%;font-style:italic;color:#333">{{ u.phone or '' }}</td>
<td style="width:5%;padding-left:20px">Fax:</td>
<td colspan="2" style="width:20%;font-style:italic;color:#333">{{ u.fax or '' }}</td>
<td style="padding-left:10px;width:16%">Tel: </td>
{% if doc.company %}      
    {% set u = frappe.get_doc("Company", doc.company) %}           
{% endif %}
<td align="right" style="width:11%;font-style:italic;color:#333">{{ u.phone_no or '' }}</td>
<td style="padding-left:10px;width:13%">Fax:</td>
<td align="right" style="width:10%;font-style:italic;color:#333">{{ u.fax or '' }}</td>
</tr>
<tr>
<td style="width:5%;padding-left:20px">Email:</td>
{% if doc.contact_person %}      
    {% set u = frappe.get_doc("Contact", doc.contact_person) %}           
{% endif %}
<td colspan="5" style="width:45%;font-style:italic;color:#333">{{ u.email_id or '' }}</td>
<td style="padding-left:10px;width:16%">Issued On:</td>
<td align="right" style="width:11%;font-style:italic;color:#333;">{{ doc.get_formatted("transaction_date") or ''}}</td>
<td style="padding-left:10px;width:13%">Overdue:</td>
<td align="right" style="width:10%;font-style:italic;color:#333;">{{ doc.get_formatted("valid_till") or ''}}</td>
</tr>

</table>
</div>

<!---End:Header--->

these two place has display issue.

what happens when you type the code under bench console?

We definitely need the line numbers. We are not personal debuggers.