Skip to Content
Menu
This question has been flagged

Hi, I have created a module which installs a new custom invoice template.

So from PRINT menu the user can choose either the "Standard Invoice" or the new "Custom Invoice".

I would like to remove the "Standard Invoice", what should I do? 

Is it possible to do it via XML?

Avatar
Discard

You want to override the default invoice template by your custom module?

Best Answer

There are two different ways to remove the already available report.

1) Override new report on existing (default) report.

This is simple way to hide / delete existing (default) report. While creating new report we just need to give External ID same as like existing report. In your case while you create your report you have to define it as like below.

 <report 
id="account.account_invoices"
model="account.invoice"
string="New Invoice Report"
report_type="qweb-pdf"
name="account.new_report_invoice"
file="new_report_invoice"
/>

2) Create new report and delete existing (default) report

This is complex method as compare to first. In this method we have to use <delete> tag to delete existing (default) report. While use of the <delete> tag we have to take care about noupdate parameter of <data> tag. In your case we have to define <delete> tag as like below.

<data noupdate="1">
<delete model="ir.actions.report.xml" id="account.account_invoices" />
</data>

It will helpful to you.

Thanks.


Avatar
Discard
Best Answer

If you want to override the default invoice template by your custom module, with different header and footer, refer the following code:

<openerp>
<data>
<template id="report_invoice_document_inherited" inherit_id="account.report_invoice_document">
<xpath expr="//t[@t-call='report.external_layout']" position="replace">
<t t-call="report.new_layout">
<div class="page">
<t t-set="company" t-value="res_company">
</t>
<br />

<div class="row mt16 mb16">
<div class="col-xs-5">

<br />
<div style="background:#01008A; font-size:13.5pt;font-family:&quot;Helvetica&quot;,sans-serif;color:white" valign="top">
<strong><center>Bill To</center></strong>
</div>
<address style="padding:5px 5px 5px 5px;border-width: 1px; border-style: solid; border-color: #002b49;" t-field="o.address_shipping_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>
</div>
<div class="col-xs-5 col-xs-push-2" >
<br />
<div style="background:#01008A; font-size:13.5pt;font-family:&quot;Helvetica&quot;,sans-serif;color:white" valign="top">
<strong><center>Ship To</center></strong>
</div>
<address style="padding:5px 5px 5px 5px;border-width: 1px; border-style: solid; border-color: #002b49;" t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>
</div>
</div>
<h2>
<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
<span t-if="o.type == 'out_refund'">Refund</span>
<span t-if="o.type == 'in_refund'">Supplier Refund</span>
<span t-if="o.type == 'in_invoice'">Supplier Invoice</span>
<span t-field="o.number"/>
</h2>
<div class="row mt32 mb32">
<div class="col-xs-2" t-if="o.name">
<strong>Description:</strong>
<p t-field="o.name"/>
</div>
<div class="col-xs-2" t-if="o.date_invoice">
<strong>Invoice Date:</strong>
<p t-field="o.date_invoice"/>
</div>
<div class="col-xs-2" t-if="o.origin">
<strong>Source:</strong>
<p t-field="o.origin"/>
</div>
<div class="col-xs-2" t-if="o.partner_id.ref">
<strong>Customer Code:</strong>
<p t-field="o.partner_id.ref"/>
</div>
<div class="col-xs-2" t-if="o.reference">
<strong>Reference:</strong>
<p t-field="o.reference"/>
</div>
</div>
<div class="row mt16 mb16">
<div class="col-xs-12">

<table class="table table-condensed" style="border-left:1px solid #000000;border-top:1px solid #000000;border-right:1px solid #000000;">
<thead>
<tr style="background-color:#F4F4F4;">
<th style="border:1px solid #000000;">Quantity</th>
<th style="border:1px solid #000000;">Item Code</th>
<th style="border:1px solid #000000;">Description</th>
<th class="text-right" style="border:1px solid #000000;">Price Each</th>
<th class="text-right" style="border:1px solid #000000;">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="item_no" t-value="1" />
<tr style="border:1px solid #000000;" t-foreach="o.invoice_line" t-as="l">
<t t-if="item_no%2!=0">

<td style="border-left:1px solid #000000;">

<span t-field="l.quantity"/>


</td>
<td style="border-left:1px solid #000000;">
<span t-field="l.product_id.name"/>
</td>
<td style="border-left:1px solid #000000;">
<span t-field="l.name"/>
</td>

<td style="border-left:1px solid #000000;" class="text-right">
<span t-field="l.price_unit"/>
</td>

<td style="border-left:1px solid #000000;" class="text-right">
<span t-field="l.price_subtotal" t-field-options='{"widget": "monetary", "display_currency":
"o.currency_id"}'/>
</td>
</t>
<t t-if="item_no%2==0">

<td style="border-left:1px solid #000000;background-color:#F4F4F4;">

<span t-field="l.quantity"/>


</td>
<td style="border-left:1px solid #000000;background-color:#F4F4F4;">
<span t-field="l.product_id.name"/>
</td>
<td style="border-left:1px solid #000000;background-color:#F4F4F4;">
<span t-field="l.name"/>
</td>

<td style="border-left:1px solid #000000;background-color:#F4F4F4;" class="text-right">
<span t-field="l.price_unit"/>
</td>

<td style="border-left:1px solid #000000;background-color:#F4F4F4;" class="text-right">
<span t-field="l.price_subtotal" t-field-options='{"widget": "monetary", "display_currency":
"o.currency_id"}'/>
</td>
</t>
<t t-set="item_no" t-value="item_no+1" />

</tr>
<tr style="border-top:1px solid #000000;">
<td style="border-left:2px solid #ffffff;border-top:1px solid #000000;"></td>
<td style="border-top:1px solid #000000;"></td>
<td style="border-top:1px solid #000000;"></td>
<td style="border-left:1px solid #000000;border-bottom:1px solid #000000;border-top:1px solid #000000;"><strong>Total:</strong></td>
<td style="border-bottom:1px solid #000000;border-top:1px solid #000000;"><span t-field="o.amount_total" t-field-options='{"widget": "monetary", "display_currency":
"o.currency_id"}'/></td>
</tr>

</tbody>
</table>
</div>

</div>
<p t-if="o.comment">
<span t-field="o.comment"/>
</p>
<p t-if="o.fiscal_position.note">
<strong>Fiscal Position Remark:</strong>
<span t-field="o.fiscal_position.note"/>
</p>
</div>
</t>
</xpath>


</template>


<template id="report.new_layout">
<!-- Multicompany -->
<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="report.new_layout_header" />
<t t-raw="0" />
<t t-call="report.new_layout_footer" />
</template>

<template id="report.new_layout_header">
<div class="header">
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
<div class="row mt8 mb8">
<div class="col-xs-5">
<div t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border:1px solid #000000;"/>
</div>
</div>

</div>
</template>

<template id="report.new_layout_footer">

<div class="footer">

<div t-if="company.sale_note" class="row mt16 mb16">
<div class="col-xs-6">
<div style="border:1px solid #000000;background-color:#01008A;color:#ffffff">
<strong>International Banking Detail</strong>
</div>
<div style="border:1px solid #000000;">
<div t-field="company.sale_note"/>
</div>
</div>

</div>

</div>
</template>

</data>
</openerp>


Avatar
Discard
Related Posts Replies Views Activity
1
Jul 17
2129
0
Oct 15
119
0
Sep 24
142
1
May 24
530
3
Feb 24
1923