TAX_ID problem in print format is not solved yet? I cannot believe it


I have updated ERP Next to version 12 and I have checked that this instruction prints an empty string in custom print format (the same happened to ERP Next version 11):

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

That occurs even when I have tax id value set. I have seen tabCustomer mysql table content and I have checked that tax id is there.

Just to test, I have changed that instruction by:

{{ frappe.db.get_value("Customer", doc.customer, "email_id") or "" }}

And I have seen that the e-mail that was displayed belongs to other customer, not the one the quotation is to!

If there is no solution to this bug, can you give me a clue about what python file should I see?



“print format is not solved yet? I cannot believe it”

Has this issue been reported on github and maybe also search the forum, to shed light on progress to resolve this?

Yes… I reported here and I have also seen other person reported in GitHub (Print format - Tax ID not showing · Issue #11617 · frappe/erpnext · GitHub) with no solution. He is talking about ERP Next version 9. It seems, this problem stays there for ever.

I tried to find the python code that controls that print format but it is a madness how many files there are.


I have discovered something interesting.

I have saved other customer so that he appears at the top of the customers list. Then I loaded the customer’s quotation, and surprise, the TAX ID that appeared belongs to the updated customer and not the customer the quotation is addressed to.

At last! After a lot of attempts I could do it.

I used finally this instruction:

{{ frappe.db.get_value("Customer", {'name': doc.customer_name}, "tax_id") or "" }}

Due to a strange reason, system could not link both Quotation and Customer tables. One of the attempts was to add Customer link in Quotation DocType but it did no work.

My guessing is that since Quotation table has already a field named customer, it could not link that with the Customer table and the name field.

By comparing contact_person field of Quotation DocType, I don’t really know why that link to Contact table does work and the link to Customer table does not.

This is clearly a bug from my point of view but the important thing now is that the workaround worked :slight_smile:


Fun Fact: Quotation doesn’t have a field named customer. There’s a dynamic Party Link field which depends on Quotation To(lead or customer).

Probably that is why the code never worked since there is no doc.customer?

Are you sure?


This is from a v12 test site. cur_frm.doc.customer returns undefined:

This is directly from the db as well:

Even a quick check of the JSON or the Quotation doctype would indicate that there’s no field named ‘customer’ in the quotation which frm.doc.customer can access in order for the original code to work by default unless a link field is specifically added.

When you passed { name:doc.customer_name } it is passing the correct link field to work.