odoo教程---在odoo8中创建自定义的reports
来源:互联网 发布:知乎书店 地址 编辑:程序博客网 时间:2024/05/10 01:19
http://blog.csdn.net/shanzhizi/article/details/50788815
odoo教程---在odoo8中创建自定义的reports
版权声明:本文为博主原创文章,未经博主允许不得转载。
目录(?)[+]
Hi guys
In this tutorial you will learn how to create a new QWeb report from scratch.
During this tutorial I will create a second invoice report, but this time without prices. Some companies do not want to show prices per record for example, so I’ll take this as a sample.
1. Creating a new XML file
The first step to create your own new report is to make a new XML file. This file should be placed under yourModuleName/views and you can name it as you wish. In this tutorial I will create a new invoice that is made in the module account.
I’ve named the file report_without_prices.xml as you can see here:
In this file you will define the template id’s and names, which will later on be used by your Odoo to find the correct report.
The minimal code looks like this:
So, what is important about this? The name of the template id (from the first record) should be the same as the name for the t-raw that handles translations. In the t-raw you need to add the module name before this name with a dot. Here’s an image to make things more clear:
The second template_id then needs to be identical to the name that you will set in the next file. So let us continue.
2.Add the report to the XML file responsible for reports
This brings us to part 2. Every module has a file that makes a reference to every single report in the module. This is done by a item, which can be found in the XML file.
This file always has the same name structure. It starts with the name of your module, an underscore and then report.xml. Its found in the first level of the directory of your module, as you can see here:
The filename is always yourModuleName_report.xml. Now open up this file and you will see a tag for every report that exists in this module.
The next step for us is to add a new tag for our own report. The code looks like this:
Now that you’ve added this code you’re almost there! The last step is to notify Odoo of the new report.
3. Notify Odoo from the new report
So how do we tell Odoo there is a new report? In every module is a file named __openerp__.py. This file is used to import (include) all files in a module.
As all files are loaded in here we should also add our new XML file in this list. Without this Odoo will not find or use the XML file which will result in a not working report and errors.
Add a new line to the __openerp__.py file, right under ‘data’:[
4. Wrapping things up
Now that you’ve made a new report (a new XML file),added the template id to the moduleName_report.xml file and added your XML file to __openerp__.py you’re done!
The last thing you need to do is reload your module (by command or by a module update) and you’ll see the new report showing up.
If you then look under accounting > Customer Invoices and make a new invoice you will see your new print option:
And, finally, if you print it out you’ll get your custom report!
NOTE:If you want a more advanced code, which shows a full report without the prices just paste this code in reports_without_prices.xml
Looking for more information about reports?
Check out the official documentation
文章来自:http://www.odoo.yenthevg.com/creating-custom-reports-odoo-8/
- odoo教程---在odoo8中创建自定义的reports
- odoo教程---在odoo8中创建自定义的reports
- odoo 9.0创建自定义模块
- Odoo开发教程(二):如何创建一个空的Odoo模块
- odoo8.0(原openERP)学习笔记之一——odoo自定义模块安装
- Odoo8在TreeView左上角增加自定义按钮以及通过继承生成自定义的View_Mode
- Odoo8在TreeView左上角增加自定义按钮以及通过继承生成自定义的View_Mode
- Odoo8中创建数据表index问题
- Trac - Creating Custom Reports - 创建自定义报表
- Odoo8.0在CentOS7的安装步骤
- Odoo8.0在CentOS7的安装步骤
- odoo8在py脚本中取得selection字段定义的列表
- odoo8中在“更多”下拉菜单下实现简单的批量操作
- Odoo(OpenERP)开发实践:在QWeb报表中自定义页眉页脚
- Odoo(OpenERP)开发实践:在QWeb报表中自定义页眉页脚
- Odoo(OpenERP)开发实践:在QWeb报表中自定义页眉页脚
- Odoo(OpenERP)开发实践:在QWeb报表中自定义页眉页脚
- 在tomcat中部署ctystal reports
- appdelegate
- This Handler class should be static or leaks may occur (anonymous android.os.Handler)
- 独立看门狗
- xml解析之SAX
- Android 简单的条形颜色选择器
- odoo教程---在odoo8中创建自定义的reports
- Redis中基本数据类型的操作
- 3dsMax之CoCreateInstence() failed报错
- unity获取某个方法执行时间
- 搭电路和Altium Designer
- odoo 8 qweb Report英文版
- 如何将cocos2d-x项目打包成一个.exe
- eclipse开发时常用的快捷键
- HDU 5695 Gym Class