콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
6460 화면

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

아바타
취소
관련 게시물 답글 화면 활동
1
8월 25
340
1
2월 24
3230
1
9월 19
7746
2
8월 25
479
1
7월 25
1969