i want to show the company reportheader only on the first page.I have now beautifull qweb report in PDF. But if my reports (sale order, for example) have more than one page, the header is on EACH page.
How to put company header only on the first page?
Thanks,
Header is only displayed once, in first page.report. The others are empty
<template id="report_quotation_header" inherit_id="report.external_layout_header">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<t t-set="data_report_margin_top" t-value="12"/>
<t t-set="data_report_header_spacing" t-value="9"/>
<t t-set="data_report_dpi" t-value="110"/>
<div class="row">
<div class="col-xs-3" name="company_address">
<div t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black;"/>
</div>
</div>
</div>
</xpath>
</template> <!-- end teamplate header-->
Call your header inside page div. This will print header only on first page of qweb report in odoo
in odoo 10 I have done this as follows:
<template id="custom_report_header" inherit_id="report.external_layout_header" primary="True">
<xpath expr="//div[#class='header']" position="replace">
<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>
</xpath>
</template>
<template id="your_custom_header_id" inherit_id="report.external_layout" primary="True">
<xpath expr="//t[#t-call='report.external_layout_header']" position="replace">
<t t-call="your_module_name.custom_report_header" />
</xpath>
</template>
<template id="your_report_name"
<t t-call="report.html_container">
<div class="page">
<t t-call="your_module_name.your_custom_header_id">
</t>
....
</div>
</t>
</template>
pramod24
You can use the OCA App Report Qweb Element Page Visibility.
You can use this class first-page shows an element only on the first page.
Thanks
Related
I want to migrate a module report from odoo 10 to odoo 11 but it seems that odoo 11 doesn't contain a module in addons called report. Can you help me and tell me with what I can replace it.
External ID not found in the system: report.external_layout_header" while parsing None:3, near
<data inherit_id="report.external_layout_header">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"/>
</div>
</div>
<div class="row">
<div class="col-xs-6" name="company_address">
<span t-field="company.partner_id" t-field-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}" style="border-bottom: 1px solid black; display:inline-block;"/>
</div>
<div class="col-xs-6 text-right">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
</div>
</div>
</xpath>
</data>```
Second error: Element '<xpath expr="//div[#name='customer_address']/div/div">' cannot be located in parent view
None" while parsing None:3, near
<data inherit_id="stock.report_delivery_document">
<xpath expr="//div[#name='customer_address']/div/div" position="replace">
<span t-if="o.picking_type_id.code=='outgoing'"><strong>Adresse Client:</strong></span>
<span t-if="o.picking_type_id.code=='incoming'"><strong>Adresse Fournisseur:</strong></span>
</xpath>
<xpath expr="//h2" position="replace">
<h2 t-if="o.picking_type_id.code=='outgoing'">
Bon de livraison:
<span t-field="o.name"/>
</h2>
<h2 t-else="">
Bon de réception:
<span t-field="o.name"/>
</h2>
</xpath>
In Odoo11 the "report" module is integrated with "web" module.
Replace this report.external_layout_header with web.external_layout and don't forget to add 'web' in your dependency
inherit_id="web.external_layout"
Hello, omas
Can you Please write the following code:
<data inherit_id="web.external_layout_background">
<xpath expr="//div[hasclass('o_background_header')]" position="replace">
<div class="header">
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"/>
</div>
</div>
<div class="row">
<div class="col-xs-6" name="company_address">
<span t-field="company.partner_id" t-field-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}" style="border-bottom: 1px solid black; display:inline-block;"/>
</div>
<div class="col-xs-6 text-right">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
</div>
</div>
</xpath>
</data>```
I Hope this helps you.
Thank you.
I'm trying to create a simple Qweb widget. My code is like this
<template id="contact_name">
<address t-ignore="true" class="mb0" itemscope="itemscope" itemtype="http://schema.org/Signature">
<div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'">
<span itemprop="name" t-esc="name"/>
</div>
</address>
</template>
Then I called the widget like this
<address t-field="o.partner_id" t-field-options='{"widget": "contact_name", "fields": ["name"], "no_marker": true}' />
It did not print out name but print out the object res.partner(703,)
How is it to print the name? Is it not enough to just to use <span itemprop="name" t-esc="name"/>?
<div class="page">
<div class="oe_structure"/>
<div class="col-xs-6 pull-left">
<h2 style="color:red">
<span>Plan Order :
<span style="color:Red" t-field='doc.name'/>
</span>
</h2>
</div>
<div colspan="4" class="col-xs-6 text-right">
<span>
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', doc.name, 500, 50)"
style="width:100%;height:50px"/>
</span>
</div>
I have created a custom report which inherits sale.report_saleorder and I am trying to add custom header.
<openerp>
<data>
<template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
<xpath expr="t" position="before">
<div class="head_wrap">
<div class="row">
<div class="col-xs-3">
<img t-if="res_company.logo" t-att-src="'data:image/png;base64,%s' %res_company.logo"
style="max-height: 45px;" />
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;"
t-field="res_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">
<div class="col-xs-6" name="company_address">
<span t-field="res_company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black; display:inline-block;" />
</div>
</div>
</div>
</xpath>
</template>
</data>
</openerp>
When I select report format as 'HTML', it is working without any problem. But when I print it as 'PDF', it doesn't render my header. Is there a solution for this? How can I print report with my header?
If you want to use a custom header you must inherit the report.external_layout_header, this one:
<t t-name="report.external_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 class="row">
<div class="col-xs-5">
<div t-field="company.partner_id" t-field-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}" style="border-bottom: 1px solid black;" class="pull-left"/>
</div>
</div>
</div>
</t>
So, you should inherit the header like this:
<openerp>
<data>
<template id="custom_external_layout_header" inherit_id="report.external_layout_header">
<!-- [...] -->
</template>
</data>
</openerp>
Put your custom header inside <div class="header">
Eg :
<div class="header">
<span>hi</span>
<div>
1. sudo apt-get remove wkhtmltopdf --purge
2. sudo wget
https://downloads.wkhtmltopdf.org/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
3. sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
4. sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
5. sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
Go to Accounting => Accounting Dashboard => click on Reconcile button
We get below Qweb view.
In that Qweb view, How can we hide "Automatic reconciliation" button ?
I have tried following but didn't work:
<templates xml:space="preserve">
<!-- 1st try -->
<t t-name="automatic_reconciliation_1st" t-extend="reconciliation">
<t t-jquery=".btn" t-operation="replace"></t>
</t>
<!-- 2nd try -->
<t t-name="automatic_reconciliation_2nd" t-extend="reconciliation">
<t t-jquery=".js_automatic_reconciliation" t-operation="replace"></t>
</t>
<!-- 3rd try -->
<t t-name="automatic_reconciliation_3rd" t-extend="reconciliation">
<t t-jquery=".oe_form_sheet oe_form_sheet_width o_form_sheet" t-operation="replace">
<div class="oe_form_sheet oe_form_sheet_width o_form_sheet">
<h1><t t-esc="title"/></h1>
<div t-if="! hide_progress" class="progress progress-striped">
<div class="progress-text"><span class="valuenow">0</span> / <span class="valuemax"><t t-esc="total_lines"/></span></div>
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" t-att-aria-valuemax="total_lines" style="width: 0%;">
</div>
</div>
<div class="oe_clear o_clear"></div>
<div class="notification_area"></div>
<div class="interface_options oe_form o_form"></div>
<div class="reconciliation_lines_container"></div>
<div class="show_more_container"><button class="show_more btn btn-default btn-sm">Show more... (<span class="num_items_remaining"></span> remaining)</button></div>
<p class="o_protip text-muted" align="right">Tip: Hit CTRL-Enter to reconcile all the balanced items in the sheet.</p>
</div>
</t>
</t>
</templates>
Try this .
<t t-name="account.reconciliation">
<div class="o_form_view"><div class="oe_form_sheetbg o_form_sheet_bg"><div class="oe_form_sheet oe_form_sheet_width o_form_sheet">
<h1><t t-esc="title"/></h1>
<div t-if="! hide_progress" class="progress progress-striped">
<div class="progress-text"><span class="valuenow">0</span> / <span class="valuemax"><t t-esc="total_lines"/></span></div>
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" t-att-aria-valuemax="total_lines" style="width: 0%;">
</div>
</div>
<div class="oe_clear clearer"></div>
<div class="notification_area"></div>
<div class="interface_options oe_form o_form"></div>
<div class="reconciliation_lines_container"></div>
<div class="show_more_container"><button class="show_more btn btn-default btn-sm">Show more... (<span class="num_items_remaining"></span> remaining)</button></div>
<p class="o_protip text-muted" align="right">Tip: Hit CTRL-Enter to reconcile all the balanced items in the sheet.</p>
</div></div></div>
</t>
Alternative solution:
.js_automatic_reconciliation { display:none; }
I extended the 'report.external_layout_footer' qweb view to display image.
Below is my code in the file reports/external_layout.xml:
<template id="report_footer_custom" inherit_id="report.external_layout_footer">
<xpath expr="//div[#class='footer']" position="replace">
<div class="footer">
<img t-att-src="'data:image/jpeg;base64,/var/www/cbl_openerp/openerp/cap_addons/cap_sale/img/footer.jpeg'"/>
<ul class="list-inline">
<li>Page:</li>
<li>
<span class="page"/>
</li>
<li>/</li>
<li>
<span class="topage"/>
</li>
</ul>
</div>
</xpath>
</template>
And here is my openerp.py content :
...
"depends": ["base","sale","report"],
...
"data": ['sale.xml',
'reports/reports.xml',
'reports/external_layout.xml',
'reports/informations_prestation.xml',
'views/product_template.xml',
'filter.xml'],
...
"images":['img/footer.jpeg',],
...
But when I print a sale order, i can't view my image at the bottom of the page.
Does anyone have any suggestions?
Just try this below code and set the image path from your module and run it .
<template id="report_footer_custom"inherit_id="report.external_layout_footer">
<xpath expr="//div[#class='footer']" position="replace">
<div class="footer">
<img class="img img-responsive" src="/sale_order_report/static/src/img/header.jpg"/>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</xpath>
</template>
My side its working fine in the QWeb Report Custom Footer
In case you want to use an image that isn't static, here's what you can do instead.
Using the company logo as an example:
<img
t-attf-src="data:image/*;base64,{{company.logo}}"
t-att-alt="company.name"
/>
Using the mime type "image/*" will let you use different format of image and not just jpeg or just png.
Then as odoo render by default binary data as base64, you can simply append the content of the image after base64,.
The following snippet also works for QWeb reports (Odoo v10).
<span t-field="o.product_id.image_medium" t-field-options="{'widget': 'image'}"/>
...where o.product_id.image_medium is a dynamic field.
This is for anyone working with odoo12 or an approximate version. The reports module is web and not report. Odoo introduced styled reports and this snippet extends each one of them.
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<data noupdate="0">
<!-- The external layout background header -->
<template id="external_layout_background_inherit" inherit_id="web.external_layout_background">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="o_background_header">
<div class="row" style="width: 100%; margin: 0 auto;">
<img src="extend_layout/static/src/img/header.jpg" style="width:100%;" />
</div>
</div>
</div>
</xpath>
</template>
<!-- The external layout boxed header -->
<template id="external_layout_boxed_inherit" inherit_id="web.external_layout_boxed">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="o_boxed_header">
<div class="row" style="width: 100%; margin: 0 auto;">
<img src="extend_layout/static/src/img/header.jpg" style="width:100%;" />
</div>
</div>
</div>
</xpath>
</template>
<!-- The external layout clean header -->
<template id="external_layout_clean_inherit" inherit_id="web.external_layout_clean">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="o_clean_header">
<div class="row" style="width: 100%; margin: 0 auto;">
<img src="extend_layout/static/src/img/header.jpg" style="width:100%;" />
</div>
</div>
</div>
</xpath>
</template>
<!-- The external layout standad header -->
<template id="external_layout_standard_inherit" inherit_id="web.external_layout_standard">
<xpath expr="//div[#class='header']" position="replace">
<div class="header">
<div class="row" style="width: 100%; margin: 0 auto;">
<img src="extend_layout/static/src/img/header.jpg" style="width:100%;" />
</div>
</div>
</xpath>
</template>
<!-- Remove company address from the reports -->
<template id="address_layout_inherit" inherit_id="web.address_layout">
<xpath expr="//div[#class='address row']" position="replace">
<div style="height: 50px;"></div>
</xpath>
</template>
</data>
</odoo>