Skip to Content
Menu
This question has been flagged
2 Replies
5219 Views

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?

Avatar
Discard
Author

@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

Best Answer

Could you please try with basic layout.


Avatar
Discard
Author

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>

Author Best Answer

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


Avatar
Discard
Related Posts Replies Views Activity
4
Jun 24
1699
2
Mar 24
2205
2
Jul 23
2191
0
Nov 22
2512
2
Feb 19
3679