Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
7 Відповіді
6048 Переглядів

I have a custom module that does some stuff including generating some reports in PDF. I've created a cron job to run this periodically. If I select "Run Manually", everything works as expected and my reports look great. If however the job executes via schedule, the PDF loses it's header, footer and styling.

I've done a lot of searching, but other people that are having problems are having problems regardless of how the report is executed. My problem is only when the report is executed via a cron job.

Is there something I'm missing on permissions perhaps? What could be different between the execution methods, manually through the UI versus scheduled?

I'm on Odoo 9 and wkhtmltopdf 12.3.2 (with patched qt) on Windows 8.1 as my dev machine. The problem also occurs on Ubuntu 14.04, Odoo 9, wkhtmltopdf 12.2.1 (with patched qt).

Аватар
Відмінити
Найкраща відповідь

Hi,

As first suggestion try to downgrade the wkhtmltopdf to 12.1 and try again, and let us see if there any changes ?

 

Аватар
Відмінити

This is most likely the issue. Wkhtmltopdf 12.2.x is not officially supported for Odoo.

Автор

I've now tried 12.1.2 and the problem persists. Any other ideas? It's strange that it's only when scheduled. Could current directory or permissions be an issue?

Найкраща відповідь

Although reported as Resolved, I believe it's not.

I'm suffering the same error while debugging I found inside function _run_wkhtmltopdf in file report.py there's a try - catch statement which checks for request and passes the session id as cookie argument for wkhtmltopdf with this value wkhtmltopdf has access to the CSS files which otherwise are behind Odoo.

I wonder if there's a way to generated the html file with the CSS files inside it so wkhtmltopdf doesn't need a session in order to read these files.

Code in report.py:

try:
if request:
command_args.extend(['--cookie', 'session_id', request.session.sid])
except AttributeError:
pass

 


Аватар
Відмінити

I did finally get it working. It would appear that the process calling wkhtmltopdf isn't given the context it needs; ie; it doesn't know which database to use.

This is further complicated by the face that db-filter doesn't appear to work in the config file.

I ended up getting it working by calling python using the parameter; --db-filter=^database_name$

The ^ and $ ensure that the regex doesn't return anything other than the exact string.

I hope this fixes it for you.

Thank you, that worked!

Найкраща відповідь

I have a similar issue and i have tried all the suggestion without success. I am working with v-10. please let me know any other possible solutions thanks 


Аватар
Відмінити
Найкраща відповідь

is this problem fixed? i have same problem too. change wkhtmltopdf version to 12.1 is not solve the problem.

Аватар
Відмінити
Найкраща відповідь

Hi Michael

Follow these steps

- install wkhtmltopdf (0.12.1)

- define the system parameter report.url with the value http://0.0.0.0:[port] (the port here is the xmlrpc_port of your odoo instance)

- restart odoo

This should work

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лют. 24
2718
1
вер. 19
7360
1
трав. 25
1144
1
квіт. 25
1949
0
бер. 25
1369