Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
5365 Переглядів

I try to inherit web.external_layout to remove header and footer because I want to custom my report pdf. I try to remove t-call="web.external_layout"​ , the header and footer is gone but the page become a mess. Every page was merge into a page even in different page class. So I think I should modify the web.external_layout

Here's my attempt to do it


But I got error Element '' cannot be located in parent view​ . I tried different approach like below

- change the expression to "//div[class='header']".  got same error but with this element

- change the expression to "//div[t-attf-class='header']".  got same error but with this element


Then I think it's because header was inherited from external_layout_standard​. So I change the inherit_id to web.external_layout_standard​ and try the same way as above. But still got the same error


How can I remove the header and footer?

Аватар
Відмінити
Автор

@Cybrosys I'm making a new custom report pdf for new custom module. If I comment `external_layout`, the page will be merge to one page even I put "page" class in the div tag

External id web.basic_layout is working. thanks for the suggestion

Найкраща відповідь

Could you please try with basic layout.


Аватар
Відмінити
Автор

I tested it. when I want to have a multiple page on a single record, it's merging into one page. I want it to keep seperate

```

<t t-foreach="docs" t-as="o">
<t t-call="web.basic_layout">
<div class="page" style="background-color: #2eb9ff !important;">
<div class="oe_structure"/>
<h2>Report</h2>
<p>
<span t-field="o.label"/>
</p>
</div>
<div class="page" style="background-color: #2eb9ff !important;">
<div class="oe_structure"/>
<h2>Report</h2>
<p>
<span t-field="o.label"/>
</p>
</div>
</t>
</t>
```

You can use page break.

<t t-foreach="docs" t-as="o">
<t t-call="web.basic_layout">
<div class="page" style="background-color: #2eb9ff !important;">
<div class="oe_structure"/>
<h2>Report</h2>
<p>
<span t-field="o.label"/>
</p>
</div>
<p style="page-break-after:always;"/>
</t>
</t>

Автор Найкраща відповідь

I Found the solution. If you print the report as HTML, you can get the class of the element. Just copy the element (with all the attribute and remove anything that's not necessary)

You can completely remove the header and the footer. Then the seperate page is still working.

I think the style for seperate page is in the article

If you want to use this code, make notes that i'm using odoo 16. I recommend you to check the element from printing the report as HTML


This is for the header


This is the content


This is the footer


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
4
черв. 24
1802
Wrong PDF Format Вирішено
2
бер. 24
2324
2
лип. 23
2276
0
лист. 22
2632
2
лют. 19
3741