This question has been flagged
2 Replies
3451 Views

Hello,

I am trying to make a custom quotation layout. I would like this layout has no header but use the default footer of report.external_layout. Also, I want to style this footer.

So, in a file, I create a custom footer template which I call report.custom_external_layout and in which I add using xpath a style tag:

<template id="report.custom_quotation_footer" inherit_id="report.external_layout_footer"> <xpath expr="//div[@class='footer']" position="before">

        <style>        

            //My style

        </style>

    </xpath>

</template>


Then, I make a new layout which inherits from report.external_layout and remove the header part:


<template id="report.custom_quotation" inherit_id="report.external_layout">

    <xpath expr="//t[@t-call='report.external_layout_header']" position="replace">

    </xpath>

</template>


Last, I want call my custom layout into the definition of my report,

<template id="sale.nice_quotation">

    <t t-call="report.custom_quotation">

    <t t-foreach="docs" t-as="o">

    <div class="page quotation">

    <style>

        //My report style

    </style>

     Some HTML

    </t>

</t>

</template>

But when I want to print, odoo says me :


WebTemplateNotFound: Template 'report.custom_quotation' not found.

Maybe someone could help cause I can't see what is wrong in my code.
Thanks.

Avatar
Discard
Best Answer

Hello ,
Try this one, i think it's usable for you

Write down in report action file.

<template id="external_layout_custom">

    <t t-if="o and 'company_id' in o">

        <t t-set="company" t-value="o.company_id"></t>

    </t>

    <t t-if="not o or not 'company_id' in o">

        <t t-set="company" t-value="res_company"></t>

    </t>

    <t t-call="work_order.external_layout_header_custom" />

    <t t-raw="0" />

</template>


<template id="external_layout_header_custom">

    <div class="header" style="font-size:11px;">

            <div class="col-xs-12 text-right mt16">

                    Page: <span class="page"/>

            </div>

        </div>

</template>


External layout call in your custom report

<?xml version="1.0" encoding="utf-8"?>

<odoo> 

    <template id="report_work_order">

        <t t-foreach="docs" t-as="o">

            <t t-call="work_order.external_layout_custom">

                <div class="page">..........</page>

             </t>

     </t>

</odoo>



Avatar
Discard
Author Best Answer

Solved. It seems that I had misunderstood how odoo inheritance works. If I create an inherited template from an existing one, I haven't to call it using t-call attribute since it will be automatically called after its original.


Avatar
Discard