I have some trouble with my report header in odoo.
I can't make it appears correctly.
I've made a custom report here's the code:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_timesheet">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<div class="page">
<t t-call="report.external_layout">
#SOMESTUFF
</t>
</div>
</t>
</t>
</template>
</data>
</odoo>
The thing is my header appears twice when I run this code, I've seen from standard module example that the line
<t t-call="report.external_layout">
should be before
<div class="page">
but when I do that the header doesn't appear at all. Does anyone have any idea about what's going wrong with this?
You can create your report as following:
<template id="report_invoice_document">
<t t-call="report.external_layout">
....
</t>
</template>
<template id="report_invoice">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account.report_invoice_document" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
Related
In odoo, qweb report. I have created an inherited report whith objective to change t-call attribute value from internal_layout to external layout. i have used the next code:
<template id="!!!!!!!!!!!!" inherit_id="!!!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="attrs">{'t-call':'web.external_layout'}</attribute>
</xpath>
</template>
This code did not work, I wonder if there is a way to insert sub part of the same report.
<template id="!!!!!!!!!!!!!!!!!!" inherit_id="!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="replace">
<t t-call='web.external_layout'>
insert here original sub report
</t>
</xpath>
</template>
Operation doable by this small changment !
<data>
<template id="!!!!!!!!!!" inherit_id="!!!!!!!!!!!!!!!!!">
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="t-call">web.external_layout</attribute>
</xpath>
</template>
</data>
If your views is for multiple object, like contains:
<t t-set="o" t-value="o.with_context({'lang':o.customer_id.lang})" />
you must add others attributes modification:
<xpath expr="//t[#t-call='web.internal_layout']" position="attributes">
<attribute name="t-call">web.external_layout</attribute>
<attribute name="t-foreach">docs</attribute>
<attribute name="t-as">o</attribute>
</xpath>
I want to remove 'Unpublished on Website' button from customer form view.
This button is not part of form view so when i tried below code ,i got an error that element doesn't exist in parent view:
<xpath expr='//div[#class="oe_button_box"]//button[#name="website_publish_button"]' position='replace'>
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</xpath>
Then i tried to remove it using css. My css.css file :
button[name=website_publish_button]
{
display:none !important;
}
and template :
<openerp>
<data>
<!-- Adds all assets in Odoo -->
<template id="assets_backend" name="contacts_custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<!--These links will be called when loading your Odoo -->
<link rel="stylesheet" href="/contacts_custom/static/css/css.css"/>
</xpath>
</template>
</data>
</openerp>
But still button appears.Am i doing something wrong or Is there any other method to remove this button?
You could do it extending the view like this:
<record id="view_partners_form_website" model="ir.ui.view">
<field name="name">view.res.partner.form.website</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="website_partner.view_partners_form_website"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<data>
<button name="website_publish_button" position="replace">
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</button>
</data>
</field>
</record>
Add a depends entry to the module website_partner to be able to inherit the view that add the button like the snippet above
I need help about generate report from wizard in odoo 9. On internet I'm find one unfinished example. I want get all user is res.user where create_date (field in res.users) >= date_from and =< date_to from my wizzard.
My source:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_my_wiz_form" model="ir.ui.view">
<field name="name">print.report.form</field>
<field name="model">my.test.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Report">
<group colspan="4" >
<field name="date_from"/>
<field name="date_to" />
</group>
<group colspan="4" col="6">
<button name="print_report" string="Print Users" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_my_wiz_form" model="ir.actions.act_window">
<field name="name">Print Report</field>
<field name="res_model">my.test.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_my_wiz_form"/>
<field name="target">new</field>
</record>
<menuitem name="REPORT" id="menu_my_test_report" action="action_my_wiz_form" sequence="19"/>
</data>
</openerp>
.py file
class my_test_report(models.Model):
_name = 'my.test.report'
_description = 'Test Report'
date_from = fields.Date(string = 'From')
date_to = fields.Date(string = 'To')
def print_report(self, cr, uid, ids, context=None):
datas = {}
if context is None:
context = {}
data = self.read(cr, uid, ids,['date_from', 'date_to'], context=context)
date_from = data[0]['date_from']
date_to = data[0]['date_to']
obj = self.pool.get('res.users')
ids = obj.search(cr, uid, [('create_date','>=',date_from),('create_date','<=',date_to)])
print(ids)
datas = {
'ids': ids,
'model': 'res.users',
'form': data
}
return {
'type': 'ir.actions.report.xml',
'report_name': "XXXXXXX,
'datas': datas,
}
Hw create report_name in .py, I'm put XXXXXXXX with several fields from res.users?
After run code without
return {
'type': 'ir.actions.report.xml',
'report_name': "XXXXXXX,
'datas': datas,
}
in console get [3, 4]
I'm try with this xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_sasa_test">
<t t-call="report.html_container">
<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"/>
<t t-foreach="docs" t-as="o">
<div class="page">
<table class="table table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Test</th>
</tr>
</thead>
<tbody>
<tr>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.name"/></td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</odoo>
But after generate pdf i get two pdf page with one row i need all data on one page ---> https://postimg.org/image/gbdadtrm5/
Any solution how define this report?
etc.
id | login | signature
3 | 25.01.17 | ---
4 | 25.01.17 | ---
docs variable represents a record on your model by default unless you define it otherwise. I do not see you define it somewhere else here so your problem is that you have the t-foreach="docs" and then you create a page. The t-foreach="docs" should enclose the whole report view and not the page. Take a look at addons/account/views/report_invoince.xml as to how this loops works.
<template id="report_report_sasa_test">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="your_module.report_sasa_test" t-lang="o.partner_id.lang"/>
</t>
</t>
</template>
I found the another question at here. But there is no answer.
I got the error
QWebException: "'NoneType' object is not callable" while evaluating 'has_shortage_so_lines(data)==True'
This is my report_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- External Consumption Report -->
<!-- Landscape Paper Format-->
<record id="paperformat_LetterLandscape" model="report.paperformat">
<field name="name">US Letter Landscape</field>
<field name="default" eval="True"/>
<field name="format">Letter</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Landscape</field>
<field name="margin_top">15</field>
<field name="margin_bottom">15</field>
<field name="margin_left">2</field>
<field name="margin_right">2</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">7</field>
<field name="dpi">100</field>
</record>
<!--Report XLS-->
<report
id="action_report_shortage_xls"
model="sale.order"
string="Shortage Report"
report_type="qweb-html"
name="sale.report_shortage_xls"
file="sale.report_shortage_xls"/>
<!--Paper Format to shortage report-->
<record id="action_report_shortage_xls" model="ir.actions.report.xml">
<field name="paperformat_id" ref="stock.paperformat_LetterLandscape"/>
</record>
</data>
</openerp>
This is my report_xls.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Translatable template -->
<template id="report_shortage_xls">
<div class="workbook">
<div class="worksheet" name="Shortage Report">
<table>
<tbody>
<tr>
<td easyfx="font: height 200;align: horizontal left,vert center">Printed On :</td>
<td><span t-usertime="%d-%m-%Y %H:%M" /></td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th colspan="17" easyfx="font: height 400, bold on;align: horizontal center,vert center">Shortage Report</th>
</tr>
<!--<tr>
<th>
<span t-esc="has_shortage_so_lines(o.id)"/>
</th>
</tr>-->
</thead>
</table>
<t t-if="has_shortage_so_lines(data)==True">
<table>
<thead>
<tr>
<th easyfx="font:height 200, bold on;align: horizontal center,vert center;">Date</th>
<th easyfx="font:height 200, bold on;align: horizontal center,vert center;">SO No</th>
<th easyfx="font:height 200, bold on;align: horizontal center,vert center;">Customer Ref No</th>
</tr>
</thead>
</table>
</t>
</div>
</div>
</template>
<!-- Main template -->
<template id="xls_report_shortage">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_shortage_xls')"/>
</t>
</t>
</template>
</data>
</openerp>
This is my report.py
class ShortageReport(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(ShortageReport, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'get_date_from': self.get_date_from,
'get_date_to': self.get_date_to,
'has_shortage_so_lines': self.has_shortage_so_lines,
'get_shortage_lines': self.get_shortage_lines,
})
def has_shortage_so_lines(self, order_id):
_logger.info("sale order id >>> : %r", order_id)
lines_obj = self.get_shortage_so_lines(order_id)
if lines_obj:
return True
return False
class report_shortage_xls(osv.AbstractModel):#(models.AbstractModel):
_name = 'report.stock.report_shortage_xls'
_inherit = 'report.abstract_report'
_template = 'stock.report_shortage_xls'
_wrapped_report_class = ShortageReport
Is there any way to export the xls from odoo. Thank you so much for your helping.
Make sure here
_template = 'stock.report_shortage_xls'
it must be module name with report name, you have created report for sale.order and you have given stock module name, is it correct in your case ?
For more information you should refer our blog on Qweb Report.
I'm creating a simple odoo qweb report to display some records in the database. Up to now I can create a report with some static content(hardcoded).But I want to connect my template with the table in my database. My table is Faculty. Here is my template file
`<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="ums_faculty_report">
<div class="page">
<h2>Report title</h2>
<p>This is the description</p>
<!--
In here i want to display the list of data-
<t t-foreach="dbrecords" t-as="o">
<p><t t-esc="i"/></p>
</t>
->
</div>
</template>
</data>
</openerp>`
And this is my report.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="ums.faculty_report"
model="ums.faculty"
string="All Faculties"
report_type="qweb-pdf"
name="ums.ums_faculty_report"
attachment_use="False"
/>
</data>
Simply I will repeat my problem again, I want to know how to bind a model to dbrecords in figure 1.Thanks in advance