跳至内容
菜单
此问题已终结
1 回复
2421 查看

I'm running Odoo16 in the official Docker image.

I have a custom report inheriting from sale.report_saleorder. When I view a report in HTML, it's correct, with CSS applied. I can see report_assets_common and I can see my overrides that exist within style tags in my template.

However, when I view the report in PDF, the CSS is not applied, even the report_assets_common.

I have CSS that includes @font-face like so;

@font-face {

font-family: 'Raleway';

font-style: normal;

font-weight: 400;

src: url('/branding_nusa/static/fonts/Raleway-Light.ttf') format('truetype');

}

I also have an tag like so;

The image displays correctly, but the fonts only work on HTML.

I have report.url set to 'http://localhost:8069'

I know the resource is reachable from inside the container on the report.url because I can execute this from host;

docker exec -it odoo16 curl -I http://localhost:8069/branding_nusa/static/fonts/Raleway-Light.ttf

HTTP/1.0 200 OK

Content-Disposition: inline; filename=Raleway-Light.ttf

Content-Type: application/x-font-ttf

Content-Length: 182376

Last-Modified: Fri, 24 May 2024 03:25:15 GMT

Cache-Control: public, max-age=604800

Expires: Fri, 31 May 2024 08:52:47 GMT

ETag: "1716521115-182376-3913553847"

Date: Fri, 24 May 2024 08:52:47 GMT

Server: Werkzeug/1.0.1 Python/3.9.2

In the logs, I'm seeing this;

WARNING odoo16 odoo.addons.base.models.ir_actions_report: wkhtmltopdf: Exit with code 1 due to network error: ProtocolUnknownError

It's almost like the report.url isn't being prefixed to the resource URL.

My searching has only turned up the recommendations of setting report.url, or freezing the web.base.url.

Any ideas?


Apologies for the post being screwed up. It seems that the input is not escaped and every time I post, it gets screwed up in one way or another.

形象
丢弃
编写者 最佳答案

Ok, accidentally stumbled upon the solution whilst trying to fix another problem.

Wrapping my report content in the following fixed it (note: I had to remove some of the markup as the forums don't escape content and it's trying to inject content in a code block as HTML);

        div class="article" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')"

It's not clear to me why this would have the impact that it does. There's nothing there that relates to resolution of the resource URLs. It feels more like a bug with this fix being an unintended side-effect.

ATTENTION ADMINS: The forums are seriously screwed up. Pasting HTML into code tags completely destroys the post. It's clearly not working as it was intended to.

形象
丢弃
相关帖文 回复 查看 活动
2
9月 23
6925
1
9月 22
2443
0
2月 22
3075
1
7月 17
3368
1
6月 25
10482