Skip to Content
Menu
This question has been flagged
1 Reply
2872 Views

Hello,

I have made a custom module to use my own invoice template. I have put all styling information directly into my report view xml. But now I really want to put all css into a separate file.
Therefore I created a css file in the following path /my_invoice_report/static/src/css/invoice_style.css

Now I want to include this file to my view, but it is not recognized.

The beginning of my view looks like this:

<odoo>  
    <data>   
        <template id="account_invoice_print" inherit_id="account.report_invoice_with_payments">     
            <xpath expr="//t[@t-call='web.html_container']" position="replace">       
                <link href="/my_invoice_report/static/src/css/invoice_style.css" rel='stylesheet' />       
                <t t-call="web.html_container">         
                    <t t-foreach="docs" t-as="o">
                        <div class="article">             
                            <div>               
                                <p align="right"><img t-att-src="'data:image/png;base64,%s' % to_text(o.company_id.logo)"/></p>

Can anybody tell my, what I am doing wrong?


Regards

Lars

Avatar
Discard
Best Answer

I never customized reports, but if it works like web templates (and I guess it does, because both use the lxml.etree lib), you should add the stylesheets in a less file which will be compiled in CSS by the engine. Put the less file in [your_module]/static/less directory. Then add an "asset" template with an XPATH expression to call the less file in the report header (or elsewhere). Put the assets.xml file in the view folder.

I think that report headers are in https://github.com/odoo/odoo/tree/11.0/odoo/addons/base/report

You can easily found tons of sample from website modules, but I can provide one if needed.

Avatar
Discard
Related Posts Replies Views Activity
3
Jan 20
5827
1
Feb 23
8988
0
Feb 18
4162
0
Oct 24
3646
4
Nov 24
5239