PDF shows only {{ body }}

Hi all,

as of today I cannot print PDFs from ERPNext. However, the preview still works perfectly.

  • The full page view and the PDF show only {{ body }}.

  • The error is independent of the selected Print Format and Print Style.

  • I was not able to reproduce the error on a development instance with the same frappe/erpnext/wkhtmltopdf versions.

  • There is no error message (I checked the browser console, Error Log in UI, error logs in ~/frappe-bench/logs/).

  • I tried to reinstall wkhtmltopdf, bench clear-cache and bench restart.

Any ideas how and where I could find the problem?

Versions

Ubuntu 18.04.4 LTS
frappe v12.4.1 (version-12)
erpnext v12.6.0 (version-12)
wkhtmltopdf 0.12.5 (with patched qt)

1 Like

@rmeyer It’s an issue related with wrong code or low memory at your server, wrong code on the template

This {{ body }} issue is caused by jinja, and you will need to verify the sintaxe of you templates, or if you have enought memory or space left on /tmp, to the reports run fine.

Thanks for your hints, Max!

The error also happens for “Standard” templates. If this code is wrong, everybody would have the same problem.

RAM usage is at 84% but there’s still plenty of swap space available:

image

Disk usage is at 23%:

image

This fix didn’t help, unfortunately:

I think this because the Access Log naming series
Try to open Access Log list and see the last number, after that open the tabSeries from database and see the number of space key, if it smaller than the last access log number, then change the number of key space to be equal the last access log

5 Likes

Very interesting, thanks for the hint!

Indeed, trying to open a private file, I got this error:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 324, in db_insert
    ), list(d.values()))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 156, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry 'AL-00302' for key 'PRIMARY'")
  • The most recent Access Log had the name AL-00810.
  • Autoname for Access Log was defined as “format:AL-{#####}”.
  • There was no row like "AL%" in tabSeries.

I wanted to correct the Naming Series but it didn’t show up in the Naming Series Tool.

The following two SQL statements fixed the problem for me:

UPDATE `tabDocType` SET autoname = 'AL-.#####' WHERE name = "Access Log";
INSERT INTO tabSeries VALUES ('AL-', 810);
COMMIT;

After this, I did a bench clear-cache && bench restart.

I can show very clearly that when I change Access Log’s autoname to format:AL-{#####} the error comes back again.

1 Like

you should not change the autoname - just change the last number of the space key.
Access log has not naming series.

What do you mean by space key?

As I think**
tabSeries have tow columns

  1. key: ex. HR-EMP-
  2. Value: ex. 734
    so, the naming series of Access Log Doctype is space " "
    sorry not space it is empty.:sweat_smile:
--access your system, then users and go to access log, order by last modified (descending), check the last value, e.g. AL-233601

--Go to your frappe-bench folder on the cmd, and do as below

bench --site site1.local mariadb

--then run an update of tabSeries table as below, with the last number on the access log: AL-233601

update `tabSeries` set current=233601 where name in(" ");

--In my case, I got this error after I updated Employee naming series, while changing from using Employee Number, to Naming SeriesPreformatted text

I just resolved it by adding hostname in site_config.json file. I find solution from https://discuss.frappe.io/t/print-pdf-showing-body/46068