コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

How to add custom fonts to QWeb reports?

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
qwebreportingfontsodoo8.0
6 返信
70076 ビュー
アバター
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys,

Has anybody had any succes adding a custom font to a QWeb report?
My initial idea was to add a CSS file that references the font file but that doesn't seem to work. In my module I've made static/src/css and added a file mylayout.css. In this file I've added the following:

 @font-face 
{
    font-family: cool_font;
    src: url('nexa.otf');
}
h1
{
font-family:cool_font;
color:blue;
text-align:center;
}

I've added the CSS file to my __openerp__.py:

 # any module necessary for this one to work correctly
    'depends': ['sale','project','product'],

 'css':'static/src/css/usentric.css',
    'data': [
        # 'security/ir.model.access.csv',
	'linker_report.xml',
        'views/report_saleorder_expand.xml',
        'templates.xml',
	#This creates the default items in the model sale.order.printorder, so we don't ever have to create it manually.
	'defaultdata.xml',
	'security/ir.model.access.csv',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo.xml',
    ],

But doing so did not change anything to my report. Neither the font is used and neither is the color applied. So then I decided to give it a try with inline css (style). My code:

<h1 style="font-family:cool_font; src:url('nexa.otf');">This is to test my custom font.</h1> 

But this doesn't work either. I've added the .otf file on the same level as the XML report file. I'm 100% sure the code works because I've tested this in a basic HTML page and the font is rendered.
So, what am I missing / doing wrong and has anybody got this working?


Thanks,
Yenthe

7
アバター
破棄
Deepa Venkatesh

@Yenthe, Can you please answer this query of mine. Thanks. https://www.odoo.com/forum/help-1/question/odoo9c-how-to-add-custom-fonts-to-qweb-reports-104960

アバター
Axel Mendoza
最善の回答

Hi Yenthe

First the css that you declare in the file mylayout.css is not used because of this:

css and style declarations It's working ok, just a little more hard than expected, I just test it locally by modifying the saved view in the database for my working layout view(website module override original report layout) to add my style(ugly yeah), the scenario work by collecting the styles defined in the head of the report document, as you said is not working for the body of the report document, at least for pdf, for html is ok. The way to go is extend the report layout to add your css files or styles to the head or create a new report layout to ensure that your css is loaded in the head only for your target report template. I test it by changing the color and it works in html and pdf reports. The same apply for your needs. With that fixed you could now try again all the methods for including your custom font, including the following:

Second your custom font won't will be picked by wkhtmltopdf, but you could declare it in another way. for example:

Full explanation here:

http://blog.shahariaazam.com/use-google-web-fonts-for-wkhtmltopdf-tools/

<style type="text/css"> 
@font-face {     font-family: cool_font;     font-style: normal; font-weight: 400; src: url(data:font/opentype;charset=utf-8;base64,d09GRgABAAAAAD00AA4A---[large string ommited]----3MAuAH/hbAEjQA=) format("woff"), url(data:font/truetype;charset=utf-8;base64,AAEAAAARAQAABAAQRFNJRwAAAAEAAJUIAAA---[large string ommited]-----wAAAAAAAAAAAAEAAAAA) format("truetype");
} h1{     font-family:cool_font;     color:blue;     text-align:center;  }
</style>

8
アバター
破棄
Yenthe Van Ginneken (Mainframe Monkey)
著作者

Thanks for the reply Axel. What exactly do you mean with you can declare the same inside the report template? Do you mean to add everything between style= or? Its pretty strange that you need to base64 encode your font family by the way.. :/

Axel Mendoza

I mean like using . I update my answer to include those tags. That need to be declared as part of your report template. It's rare but it's a solution

Axel Mendoza

I mean style tag definition. Odoo forum delete the tag style in the previous comment. The answer is ok

Yenthe Van Ginneken (Mainframe Monkey)
著作者

@Axel thanks for the update. I did try the method of adding the CSS within the XML template but that doesn't get rendered either. Not even the color for example, so this makes me believe CSS inside the XML templates does not work?

Axel Mendoza

Docs said: Useful Remarks Twitter Bootstrap and FontAwesome classes can be used in your report template Local CSS can be put directly in the template Global CSS can be inserted in the main report layout by inheriting its template and inserting your CSS

Yenthe Van Ginneken (Mainframe Monkey)
著作者

@Axel I've tried adding CSS in the latest runbot for simply centering and coloring a H1 in a report and that doesn't even work. Perhaps this never even worked in Odoo? Any ideas?

Axel Mendoza

I edited my answer with the solution to load css and styles, explaining why did not work before

アバター
Cyril
最善の回答

Hello

In odoo v10, it seems to be super easy... That's what we did with google font Roboto :

- Inherit css with google :

<xpath expr="." position="inside">
    <link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed" rel="stylesheet"/>
</xpath>

- Inherit the reports with font-family :

<xpath expr="//div[@class='page']" position="attributes">
    <attribute name="style">font-family: 'Roboto', sans-serif;</attribute>
</xpath>

- Inherit the header and footer with font-family :

<xpath expr="//div[@class='footer']" position="replace">
    <div class="footer" style="font-family: 'Roboto Condensed', sans-serif;">
...

It works with wkhtmltopdf 0.12.1


7
アバター
破棄
Ermin Trevisan

Can you please explain which css file should be inherited with google? Could you provide an example of the complete xml file?

アバター
Jose David Moreno Hernandez
最善の回答

In case someone is looking for an Odoo v12 approach:

If you just need your custom font to be rendered in your HTML reports. In your custom css file you can:

body{    
    font-family: 'Montserrat', sans-serif;
}

And then, in your assets.xml file you could inherit the report_assets_common in this way:

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
        <template id="report_assets_common" name="Technical Service Assets Reports" inherit_id="web.report_assets_common">
            <xpath expr="//link[last()]" position="after">
                <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"/> /*Here your chosen Google Font or any other*/
                <link rel="stylesheet" href="your_custom_module/static/src/css/report_styles.css"/> /*This is your custom css file*/
            </xpath>
        </template>
</odoo>

Finally add both files if not already there in your __manifest__.py:

'data': [
    'views/assets.xml',
],
'css': [
    'static/src/css/report_styles.css',
],

But this doesn't work that easy with pdf rendering. In that other case, following the @Cyril concept:

 This is for PDF printing reports:


Same as before, append your new fonts to the assets:

<?xml version="1.0" encoding="utf-8" ?>
<odoo>        
    <template id="report_assets_common" name="Technical Service Assets Reports" inherit_id="web.report_assets_common">           
        <xpath expr="//link[last()]" position="after">                 
            <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"/> /*Here your chosen Google Font or any other*/                 
            <link rel="stylesheet" href="your_custom_module/static/src/css/report_styles.css"/> /*This is your custom css file*/            
        </xpath>         
    </template>
</odoo>

You could inherit your chosen layout, in this case I'll take the external_layout_standard, and assign the styles to those part of the template you want to be affected. I'll change everything, so I'll select the header, article and the footer. Don't forget to appent to the __manifest__.py and upgrade your module after all.

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <data>
        <template id="external_layout_standard" inherit_id="web.external_layout_standard">           
            <xpath expr="//div[@class='header']" position="attributes">
                <attribute name="style">font-family: 'Montserrat', sans-serif;</attribute>
            </xpath>
            <xpath expr="//div[@class='article']" position="attributes">
                <attribute name="style">font-family: 'Montserrat', sans-serif;</attribute>
            </xpath> 
            <xpath expr="//div[@class='footer']" position="attributes">
                <attribute name="style">font-family: 'Montserrat', sans-serif;</attribute>
            </xpath>
        </template>
    </data>
</odoo>
3
アバター
破棄
Fady Noor Ilmi Lubis

thank you for making it clear for the PDF

アバター
EasyPME
最善の回答

Here is the complete xml for inheriting css :

<template id="my_module.report_assets_common" name="my_module report assets common" inherit_id="report.assets_common">
    <xpath expr="." position="inside">
        <link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed" rel="stylesheet"/>
    </xpath>
</template>
2
アバター
破棄
アバター
GabrielLuke
最善の回答

Generically, you can use a custom font using  @font-face  in your CSS. Here’s a very basic example:
@font-face {
font-family: 'YourFontName'; /*a name to be used later*/
src: url('http://domain.com/fonts/font.ttf'); /*URL to font*/
}

Then, trivially, to use the font on a specific element:

`.classname {`
`    font-family: 'YourFontName';`
`}`
.classname {
    font-family: 'YourFontName';
}
``
(.classname is your selector).

Note that certain font-formats don’t work on all browsers; you can use some generator to avoid too much effort converting.

You can find a nice set of free web-fonts provided by Google Fonts (I can’t insert more than 1 link so you can go to Google fonts) (also has auto-generated CSS  @font-face  rules, so you don’t have to write your own).

while also preventing people from having free access to download the font, if possible

Nope, it isn’t possible to style your text with a custom font embedded via CSS, while preventing people from downloading it. You need to use images, Flash, or the HTML5 Canvas, all of which aren’t very practical.

I hope that helped!

0
アバター
破棄
アバター
Atharva System
最善の回答

You can try check this module. https://apps.odoo.com/apps/modules/15.0/advanced_report_templates/

0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
How to change fonts in QWeb Reports v11.0
qweb reporting fonts v11.0
アバター
アバター
アバター
アバター
4
4月 18
17507
How to check checkbox state in QWeb report? 解決済
qweb reporting checkbox odoo8.0
アバター
アバター
1
3月 15
13679
How can I display all tasks (including completed ones) in a QWeb report in Odoo?
qweb reporting
アバター
アバター
2
9月 24
3049
Odoo 8 Reporting : Change default "Total" label 解決済
reporting odoo8.0
アバター
アバター
1
3月 22
8198
How do i create report in Qweb? 解決済
qweb reporting
アバター
アバター
アバター
アバター
アバター
5
8月 19
47546
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now