Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
31451 Lượt xem

Hello all!

How to put «   » in qweb report like in HTML?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

There are quite a few ways to do this. 
I like to use the CDATA way as it is build for this kind of jobs in XML. 

<![CDATA[
&nbsp;
]]>

TIP: You can use any special HTML character in CDATA for example.

Ảnh đại diện
Huỷ bỏ
Tác giả

thanks

No problem and best of luck! By the way please consider upvoting/accepting an answer (or answers) if they've helped you! :)

+1 from me.

Thank you, Yenthe :)

Thank a lot Yenthe.

And it works for qweb and xml views

Câu trả lời hay nhất

@Pascal, I have found that &amp;nbsp; works for me. I'm not sure if this is the correct way to do it according to W3C guidelines on XML/XHTML, but it has worked for me for Odoo in 8.0.

Ảnh đại diện
Huỷ bỏ

Luke its no safe way for sure and I even believe it is against the XML rule as its no default syntaxis. So I'd place it in a CDATA to be sure.

@Yenthe, Good to know. It seems to be all over the place in Odoo's core code however (which is where I came across it in the first place): https://github.com/odoo/odoo/search?utf8=%E2%9C%93&q=%26amp%3Bnbsp%3B Is this something you think I should open an issue and/or issue some PR's for? As far as i'm aware Google uses W3C compliance as a part of their search engine ranking algorithms so it may be worth replacing it with the proper syntax/markup if this is the case.

@Luke I think this is something they should look at yes. They should really provide a solution for putting spaces and tabs inside a report too, both for their own and the community to use. So perhaps a request / wishlist request for this would be nice. As for Google, I do not think their robots parse this deep and can access those files? The elements are already 'translated' when they show up in the browser so I don't think it affects ranking.

Tác giả

Perfect for me. I take this notation. Thanks a lot misters!

Câu trả lời hay nhất

I use this hack

<t t-set="foo" t-value=" '     '.replace(' ',u'\xa0').encode('utf-8') "/>
<t t-esc="foo"/>

in this way you can replace all instances of spaces

<t t-set="foo" t-value="o.name.replace(' ',u'\xa0').encode('utf-8')"/>

Ảnh đại diện
Huỷ bỏ
Tác giả

thanks