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

I have a model that has fields.Html field in it. And for instance I have a table in it and text in 2 columns. Odoo adds its classes automatically so it has style on it. But when I make the QWeb report and add that html field in it using t-out it loads html structure correctly but without style. so the table does not have borders the text that should've been 2 column is just 1 column text. How can i load odoo's scss to my module.


I tried using t-call-assets web.assets_frontend but that did not work

Avatar
Discard
Best Answer

1. Add the HTML field in your report template with safe rendering:

​<t t-raw="object.html_field"/>


2. Define your own <style> block inside the report QWeb template


  • Add basic table styling inline in your template, like this:


​<t t-name="your_module.report_template_name">

​  <t t-call="web.html_container">

​    <t t-set="doc" t-value="doc"/>


​    <style type="text/css">

​      table {

​        width: 100%;

​        border-collapse: collapse;

​      }

​      th, td {

​        border: 1px solid black;

​        padding: 5px;

​        text-align: left;

​        vertical-align: top;

​      }


Important Notes

  • Avoid t-call-assets inside reports; they are meant for HTML web views, not PDF reports.
  • Even if you're printing reports in HTML (not PDF), the safest route is still to define the CSS directly.
  • If your HTML content uses classes like .row or .col-6 (like Bootstrap), you need to manually define those classes in your <style> section, because they are not included by default.


Thanks & Regards, 

Company : DataInteger Consultancy Services LLP

Avatar
Discard
Author

In Odoo17 t-raw is deprecated so you should use t-out. that was not the problem. I solved it long ago because I got no replies. you should just call any of the layouts. I used t-call web.basic_layout and that loaded all styles defined in web module correctly.

Related Posts Replies Views Activity
0
Dec 23
1780
2
Jul 23
4899
1
Jun 23
3272
1
Apr 23
4137
1
Nov 22
2925