Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Can't manage to use a custom layout in Odoo 8

By
Aurélien Rivet
on 2/29/16, 9:22 AM 652 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.

2
Akash Balar
On 3/14/16, 12:39 AM

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>



0
Aurélien Rivet
On 3/12/16, 6:09 AM

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.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 2/29/16, 9:22 AM
Seen: 652 times
Last updated: 4/11/16, 1:10 PM