Error: “Company None not found” (Jinja Templates)

Hi everyone,

I have an issue using Jinja Templates. It always gives “Company None not found”.

I guess it is coming from the part: {% set company = frappe.get_doc("Company", doc.company) %}

I am using ERPNext 13.

Any help is so much appreciated as this is driving me nuts…

Thank you!

Hi @DrZ0idberg

I am not sure for which doctype print format you are using it … depending on that its as simple as just using the below jinja (for example in case of Pick List, Sales Order doctype etc.)

{{ doc.company }}

What are you trying to achieve with frappe.get_doc ??

I am using it for the invoice print doc. I want to add company information such as address and so on (from seller and buyer).
I have to admit I am pretty new to this and used this template:

https://github.com/alyf-de/erpnext_druckformate/blob/main/print_format/sales_invoice.html

I have tried the template you have shown…

It works for me though… Did you add multiple companies ???
If its only one company then there should not be a problem.

So assuming you want to create a custom print format for Sales Invoice, the first thing you would need to do is open the “Sales Invoice” Doctype in a separate windows as you see below.

Look at the name column… those are the field you need to use in your print format.
For example to get the customer name the jinja way will be

{{ doc.customer_name }} as that is part for the doctype.

You use frappe.get_doc and other api when you want to fetch/ pull values from a different doctype.

Then in another window go to Print Format list.

Create a new Print Format

Select ‘custom format’

Select the doctype as 'Sales Invoice ’ in this case

then go from there.

You can follow this tutorial on creating a simple custom print format and go through them… if you need any help let me know

https://github.com/rtdany10/erpnext_print_format

1 Like