I want to create a qweb report that shows all tickets related to a product:
This is what I have:
<report id="website_helpdesk_support_ticket.print_support_request"
model="helpdesk.support"
report_type="qweb-pdf"
string="Ticket"
name="website_helpdesk_support_ticket.support_report"
file="website_helpdesk_support_ticket.support_report"/>
<template id="website_helpdesk_support_ticket.support_report">
<t t-foreach="docs" t-as="doc">
<t t-call="web.external_layout">
<h1>Information about the ticket:</h1>
<span t-field="doc.product.default_code"/>
...
<h1>Related Tickets</h1>
<t t-foreach="docs.filtered(lambda x: x.product.barcode == doc.product.barcode)" t-as="related_ticket">
<span t-field="related_ticket.request_date"/>
</t>
</t>
</t>
</template>
But it shows only 1 ticket.
Thank you
your code should be as following:
<template id="website_helpdesk_support_ticket.support_report">
<t t-foreach="docs" t-as="doc">
<t t-call="web.external_layout">
<h1>Information about the ticket:</h1>
<span t-field="doc.product.default_code"/>
...
<h1>Related Tickets</h1>
<t t-foreach="docs.filtered(lambda x: x.product.barcode == doc.product.barcode)" t-as="related_ticket">
<span t-field="related_ticket.request_date"/>
</t>
</t>
</t>
</template>
<template id="support_ticket_report">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.user_id.lang"/>
<t t-call="website_helpdesk_support_ticket.support_report" t-lang="lang"/>
</t>
</t>
</template>
<report id="website_helpdesk_support_ticket.print_support_request"
model="helpdesk.support"
report_type="qweb-pdf"
string="Ticket"
name="website_helpdesk_support_ticket.support_ticket_report"
file="website_helpdesk_support_ticket.support_ticket_report"/>
Solved it with:
p_tickets = fields.Many2many('helpdesk.support', 'product_ticket_rel', 'product_id', 'ticket_id', string='Tickets')
<t t-foreach="docs.product.p_tickets" t-as="related_ticket">
<span t-field="related_ticket.request_date" t-options ='{"format": "dd/MM/yyyy"}'/>
</t>
Related
I create template in module labs.
<template id="worbook_employee_miss_message">
<t t-if="time_research">
<div>
<span style="color: red">test</span>
</div>
</t>
</template>
I call it in formview
<t t-call="labs.worbook_employee_miss_message">
<t t-set="time_research" t-value="time_research"/>
</t>
But there is no block div on form. time_research field is not empty.
I tried your code and it's ok. Be sure to call the template inside a
<div class="page">
</div>
<template id="report_label">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="example_class">
<t t-esc="o.name" />
<t t-esc="o.type" />
<p>Size: <span t-esc="o.calculate_size()"/></p>
<p>Color: <span t-esc ="o.calculate_color()" /></p>
<p>Price: </p>
<tr><td colspan="2"><img t-att-src="'/report/barcode/Code128/%s' % 'test-0001'" style="width:100%;height:25px"/> </td></tr>
</div>
</div>
</div>
</t>
</t>
</template>
this is my template and for some reason, barcode is not showing up.
if I test in http://localhost:8069/report/barcode/Code128/test-0001 then it returns me a barcode.
and reportlab is also installed.
same result but smaller borders with
<img t-if="o.barcode" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' %('Code128',o.barcode,250,50)"/>
is Settings > System Parameters need to change
Key report.url
Value http://0.0.0.0:8069
I am working with qweb reports in odoo 10 . Here is what i did
<odoo>
<template id="report_customer">
<t t-call="report.html_container">
<t t-set="data_report_margin_top" t-value="50"/>
<t t-foreach="range(5)" t-as="1">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page example-css-class">
<h2>Report title</h2>
<p>This object's name is
<span t-field="o.full_name"/>
</p>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</t>
</t>
</t>
</t>
</template>
</odoo>
and i also tried this
<odoo>
<template id="report_customer">
<t t-call="report.html_container">
<t t-set="data_report_margin_top" t-value="50"/>
<t t-foreach="range(5)" t-as="1">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page example-css-class">
<h2>Report title</h2>
<p>This object's name is
<span t-field="o.full_name"/>
</p>
<div class="footer" style="text-align: center !important;">
Page <span class="page"/> of <span class="topage"/>
</div>
</div>
</t>
</t>
</t>
</t>
</template>
</odoo>
but in both cases i am not able to see page numbers. I also tried adding custom header and footer in separate templates but that also doesn't work.
Try this :
<div class="footer">
<div class="row">
<center><span>Page </span><span class="page" /> of <span class="topage" /></center>
</div>
</div>
It works perfectly for me.
Note : I have used without calling report.external_layout
Please try this code for page number in Qweb-report. It will automatically display page no.
<t t-call="report.external_layout"></t>
I have tried to add a new page beginning of sale order report by inherit and xpath. But it not work.
Here is the code:
<template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
<xpath expr="//t[#t-call='report.html_container']" position="before">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="page">
<h1>New Page</h1>
</div>
</t>
</t>
</xpath>
But i edited in core module Sale like below and it works.
<template id="report_saleorder">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="page">
<h1>New Page</h1>
</div>
</t>
</t>
<t t-call="report.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>
How can i achieve this in my custom module?
Add dependency of "sale" module in your module and try below code
<template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
<xpath expr="t" position="before">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="page">
<h1>New Page</h1>
</div>
</t>
</t>
</xpath>
</template>
Hi Friends I have used Qweb to generate the pdf report in odoo 9 now i can download the pdf file but the file does not showing the data
Generated PDF
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_invoice">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<h2 class="text-center" style="font-size: 24px;font-weight: bold;">company </h2>
<p>This object's name is <span t-field="o.name"/></p>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>
i have changed the return of the function which will print the pfd it worked for me
return {
'type': 'ir.actions.report.xml',
'report_name': 'module.report_invoice',
'datas': datas,
}