Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
415 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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.

Powiązane posty Odpowiedzi Widoki Czynność
0
gru 23
1807
2
lip 23
4901
1
cze 23
3278
1
kwi 23
4140
1
lis 22
2928