我花了5个多小时在google上搜索关于在Odoo9.0中创建报告,但仍然没有,我想做一个类似树视图的报告,在pdf中,使用Qweb,所有我找到的都是发票,但我不知道如何在我的例子中做报告。
例如,假设我在odoo的示例中有一个包含模型(example.py,init.py)和view(example_view.xml)文件夹和init.py,openerp.py,您知道最简单的模块,我的问题是:告诉我必须添加什么,在哪里,我必须写什么来创建一个简单的报告,它看起来像树视图(这个视图在视图中),而没有更多。
我是个以身作则的人,我需要以身作则来理解一些事情。
谢谢你的回答:)
发布于 2016-08-31 16:01:23
要创建一个简单的报告,请执行以下操作。
在数据部分中使用其他xml文件。
'data': ['views/example_report.xml'],如果在列表视图中为您添加注释,您应该能够选择一条记录(选中复选框),然后在更多下拉列表中运行报告。或者在模型的表单视图中,您还应该能够单击“更多”并从那里运行报告。
注意:必须正确安装wkhtmltopdf才能工作。在wkhtmltopdf.org中有说明(确保版本至少为0.12.1 )
下面是一个简单的xml报表定义。假设您有一个具有名称(char)和子记录( example.model_name )的虚构模型one2many,子记录模型有一个id、name和date字段。
<openerp>
<data>
<report
id="report_example_model_name"
model="example.model_name"
string="Example Report"
name="example.report_example_report_view"
file="example.report_model_name"
report_type="qweb-pdf"/>
<template id="report_example_report_view">
<t t-call="report.html_container">
<!-- REMEMBER, docs is the selected records either in form view or checked in list view (usually). So the line below says use the following template for each record that has been selected. -->
<t t-foreach="docs" t-as="doc">
<t>
<div class="page">
<h1>Report For <t t-esc="doc.name"/></h1>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Date</th>
</tr>
<t t-foreach="doc.subrecord" t-as="o">
<tr>
<td><t t-esc="o.id"/></td>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.date"/></td>
</tr>
</t>
</table>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>https://stackoverflow.com/questions/39251425
复制相似问题