This question has been flagged
3 Replies
19316 Views

I am creating a custom QWeb report, but I find that when using t-field, not all CSS styling is reflected.

For e.g.

<div class="col-xs-8 text-right"
                             style="color:green;font:italic 14px lucida-console, sans-serif"
                             t-field="company.partner_id"
                             t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true }' />

The output is in 14px Lucida-Console text, but it is not italic nor green!

I tried including "style":"color:green;font:italic 14px lucida-console, sans-serif" inside t-field options, but there is no difference. How do I have to code to reflect all styling?

Avatar
Discard
Author Best Answer

Thank you both for your inputs. But even after using !important, it didn't work. I did notice that if I remove t-field-options, then the formatting applies correctly. So I'm not sure what exactly is causing the problem. For now, I have resolved it by displaying each property separately instead of using the widget:

<div class="col-xs-8 text-right" style="font:15px lucida-console,sans-serif !important;" >
    <span style="color:grey !important;" t-field="company.partner_id" /><br/>
    <span style="color:grey !important;" t-field="company.partner_id.street" /><br/>
    <span style="color:grey !important;" t-field="company.partner_id.street2" /><br/>
    <span style="color:grey !important;" t-field="company.partner_id.city" /><br/>
    <span style="color:grey !important;" t-field="company.partner_id.country_id" /><br/>
</div>

This outputs the text with all the formatting, but not an elegant solution. I will update in case I do find an alternative.

Avatar
Discard
Best Answer

Hello!

Try to put "!important" after them, like this:

<div class="col-xs-8 text-right"
                             style="color:green !important;font:italic 14px lucida-console, sans-serif !important;"
                             t-field="company.partner_id"
                             t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true }' />

Avatar
Discard
Author

Thanks Abraham, but unfortunately, this does not seem to be working either. Do you have anything else in mind? Its becoming a major problem for me in creating reports.

I don't know what is wrong because I'm using this "

" and is working fine =/
Best Answer

!important after the css directive should work, also make sure you apply it on the actual tag you want changed not on the parent

Last but not least if you are dealing with invoices make sure the report does not have "Reload from attachment" ticked

Also go to: http://odoo-address:port/report/html/module.report_template_name/database_id and try editing the css directives there for easier debugging

 

 

Avatar
Discard
Author

Thanks Paul, I've ensure that reload from attachment is unchecked but the problem persists. I'm using a workaround for now, as described in my answer. The URL that you gave sounds quite interesting. I was unable to make it work however. This is the link that I have constructed: http://0.0.0.0:8069/report/html/sv_sale_layout.report_saleorder_document_inherit/test Here 'sv_sale_layout' is the name of my module. 'report_saleorder_document_inherit' is the template name inside the xml and the database is 'test' . But nothing loads. In fact, it causes the server to crash, so its definitely doing something, but I guess I haven't constructed the URL correctly. Could you please tell me what the correction should be? Thanks again !

I have forgot to mention that you also should have the website module installed in order to use the html editor in this case.Check to see if it works then, and don't forget to use the database id at the end, here is a example of URL for standard reports: http://localhost:8069/report/html/stock.report_picking/10

Author

Yes, I got it to work now. Thanks!