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>
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.
No results when i try to create custum dashboard in odoo
I create a new module for custom dashboard in odoo following this tutorial : link
but always i found the same result is false, here is my code :
The result :
** model.py : **
create a dashboard model (kanban.count) and add some filed
class KanbanCount(models.Model)
_name = "kanban.count"
color = fields.Integer(string='Color Index')
name = fields.Char(string="Name")
#api.one
def _get_count(self):
quotations_count = self.env['sale.order'].search(
[('sate', '=', 'draft')])
orders_count = self.env['sale.order'].search(
[('sate', '=', 'sales_order')])
orders_done_count = self.env['sale.order'].search(
[('sate', '=', 'done')])
self.orders_count = len(orders_count)
self.quotations_count = len(quotations_count)
self.orders_done_count = len(orders_done_count)
orders_count = fields.Integer(compute = '_get_count')
quotations_count = fields.Integer(compute= '_get_count')
orders_done_count = fields.Integer(compute= '_get_count')
The Kanban View :
Create a kanban view of this above-created model
<record model="ir.ui.view" id="count_kanban_form_view">
<field name="name">Count form</field>
<field name="model">kanban.count</field>
<field name="arch" type="xml">
<kanban
class="oe_background_grey o_kanban_dashboard o_salesteam_kanban o_project_kanban "
create="0">
<field name="color"/>
<field name="name"/>
<templates>
<span t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)} ">
<div class="o_project_kanban_manage">
<a class="o_kanban_manage_toggle_button" href="#">More
<i class="fa fa-caret-down"/>
</a>
</div>
<div class="o_project_kanban_main" >
<div class="o_kanban_card_content o_visible">
<div class="o_kanban_primary_left" >
<div class="">
<center>
<span>
<span t-field="record.name.value"/>
</span>
</center>
</div>
<div>
<center>
<button
class="btn btn-primary"
type="action"
name="dashboard_sales_action_id"
string="Quotations">Quotations</button>
<button
class="btn btn-primary"
type="action"
name="dashboard_sales_order_action_id" >Sales order</button>
<h3>Custom Dashboard for Sales</h3>
</center>
</div>
</div>
</div>
<div class="o_kanban_card_manage_pane o_invisible">
<div class="col-xs-6 o_kanban_card_manage_section o_kanban_manage_view">
<div class="o_kanban_card_manage_title">
<span>View</span>
</div>
<div>
<a type="action">Quotations</a>
</div>
<div>
<a type="action">Sales Order</a>
</div>
<div>
<a type="action">Done</a>
</div>
<div>
<a type="action">Cancel</a>
</div>
</div>
<div t-if="widget.editable" class="o_project_kanban_colorpicker" >
<ul class="oe_kanban_colorpicker" data-field="color"/>
</div>
</div>
</div>
<div class="o_project_kanban_boxes" >
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.quotations_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Quotations
</span>
</a>
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.orders_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Sales Orders
</span>
</a>
<a class="o_project_kanban_box" name="" type="action">
<span class="o_value" style="overflow:visible !important">
<span t-esc="record.order_done_count.value"/>
</span>
<span class="o_label" style="overflow:visible !important">
Done
</span>
</a>
</div>
</div>
</span>
</templates>
</kanban>
</field>
</record>
<record id="kanabn_count_dashbord" model="kanban.count">
<field name="name">Kanban Dashboard</field>
</record>
Remove the "span" tag with a "t" tag.
For example:
<span t-name="kanban-box">
Simply replace above line as(closing tags also):
<t t-name="kanban-box">
try, i hope it's will be work
Thanks
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
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