To overload an existing report you need to call you report id with the id of the report to overload
Report in context menu
<report id="account_invoices" model="account.invoice" string="Invoices" report_type="qweb-pdf" name="account.report_invoice" file="account.report_invoice" attachment_use="True" attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')" />
Minimal Template
<template id="report_invoice"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> <t t-call="web.external_layout"> <div class="page"> <h2>Report title</h2> <p>This object's name is <span t-field="o.name"/></p> </div> </t> </t> </t> </template>
Translate Template
<!-- Main template --> <template id="report_saleorder"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="doc"> <t t-call="sale.report_saleorder_document" t-lang="doc.partner_id.lang"/> </t> </t> </template> <!-- Translatable template --> <template id="report_saleorder_document"> <!-- Re-browse of the record with the partner lang --> <t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" /> <t t-call="web.external_layout"> <div class="page"> <div class="oe_structure"/> <div class="row"> <div class="col-xs-6"> <strong t-if="doc.partner_shipping_id == doc.partner_invoice_id">Invoice and shipping address:</strong> <strong t-if="doc.partner_shipping_id != doc.partner_invoice_id">Invoice address:</strong> <div t-field="doc.partner_invoice_id" t-options="{"no_marker": True}"/> <...> <div class="oe_structure"/> </div> </t> </template>
<t t-call="web.external_layout" t-lang="en_US">
Barcode
<img t-att-src="'/report/barcode/QR/%s' % 'My text in qr code'"/>
<img t-att-src="'/report/barcode/? type=%s&value=%s&width=%s&height=%s'%('QR', 'text', 200, 200)"/>
Paper Format
<record id="paperformat_frenchcheck" model="report.paperformat"> <field name="name">French Bank Check</field> <field name="default" eval="True"/> <field name="format">custom</field> <field name="page_height">80</field> <field name="page_width">175</field> <field name="orientation">Portrait</field> <field name="margin_top">3</field> <field name="margin_bottom">3</field> <field name="margin_left">3</field> <field name="margin_right">3</field> <field name="header_line" eval="False"/> <field name="header_spacing">3</field> <field name="dpi">80</field> </record>
Add paperformat to report
<record id="sale.report_saleorder_document" model="ir.actions.report.xml">
<field name="paperformat_id" ref="my_module.paperformat_frenchcheck"/>
</record>
Python object
from odoo import api, models class ParticularReport(models.AbstractModel): _name = 'report.module.report_name' @api.model def render_html(self, docids, data=None): report_obj = self.env['report'] report = report_obj._get_report_from_name('module.report_name') docargs = { 'doc_ids': docids, 'doc_model': report.model, 'docs': self, } return report_obj.render('module.report_name', docargs)
Change font type link
Available fonts HERE
Add the font in stylesheet
<xpath expr="." position="inside">
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed" rel="stylesheet"/>
</xpath>
Set in the report page (no header and no footer)
<xpath expr="//div[@class='page']" position="attributes">
<attribute name="style">font-family: 'Roboto', sans-serif;</attribute>
</xpath>
Set in footer
<xpath expr="//div[@class='footer']" position="replace">
<div class="footer" style="font-family: 'Roboto Condensed', sans-serif;">
</xpath>
Change datetime format
<span t-field="o.date_order" t-field-options='{"format": "d MMMM y"}'/>
<span t-field="o.date_order" t-field-options="{"format": "yyyy-MM-dd"}" />
<span t-field="o.commencement_date" t-field-options="{"format": "dd/MM/yy"}"></span>
<span t-esc="o.order_date" t-options='{"widget": "date"}'/>
<span t-esc="time.strftime('%A, %d %B %Y',time.strptime(o.date_order,'%Y-%m-%d %H:%M:%S'))"/>
Report by server action
This case I call report generation of PDF in product.product form an action server located in mrp.production
Default report
<report id="report_product_product_pdf"
string="Print Attached PDF Drawings"
model="product.product"
name="plm.report_product_product_pdf"
report_type="pdf"
file=""
header="False"
/>
Action server by production
<record model="ir.actions.server" id="print_attached_pdf_mo">
<field name="name">Print Attached PDF Drawings</field>
<field name="model_id" ref="mrp.model_mrp_production"/>
<field name="code">
if records:
action = records.printAttachedPdf()
</field>
</record>
<record model="ir.values" id="value_print_attached_pdf_mo">
<field name="model_id" ref="mrp.model_mrp_production" />
<field name="name">Print Attached PDF Drawings</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.server,' + str(ref('print_attached_pdf_mo'))" />
<field name="key">action</field>
<field name="model">mrp.production</field>
</record>
Python side generation
class MrpProduction(models.Model):
_inherit = "mrp.production"
@api.multi
def printAttachedPdf(self):
products = self.env['product.product']
for mo_brws in self:
products += mo_brws.product_id
data = {}
data['ids'] = products.ids
data['model'] = 'product.product'
return self.env['report'].get_action(products.ids, 'plm.report_product_product_pdf', data)