Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
5400 Ansichten

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
Verwerfen
Autor

@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

Beste Antwort

Could you please try with basic layout.


Avatar
Verwerfen
Autor

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>

Autor Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
4
Juni 24
1827
2
März 24
2339
2
Juli 23
2280
0
Nov. 22
2645
2
Feb. 19
3787