Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
I will explain how to create report in v7 use rml.. please follow this code
create a folder structure inside ur custom module like
ur_modulename/report
inside this create folder create one init.py,urname.rml,report.py file
after that
1)init.py
import employee_report
2) .rml
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,1" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,2" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,2" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,2" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,3" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,3" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,3" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,4" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,4" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,4" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,5" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,5" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,5" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,6" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,6" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,6" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,7" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,7" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,7" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,8" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,8" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,8" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,9" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,9" stop="1,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="1,9" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
<paraStyle name="Table Contents" fontName="Helvetica"/>
<images/>
</stylesheet>
<story>
<para style="Standard">[[ repeatIn(objects,'employee') ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="241.0,241.0" style="Table1">
<tr>
<td>
<para style="Table Contents">Name</para>
</td>
<td>
<para style="Table Contents">Salary</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ employee.name ]]</para>
</td>
<td>
<para style="Table Contents">[[ employee.salary ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>
3)report.py
from report import report_sxw
class order(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
super(order, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
})
report_sxw.report_sxw('report.employee.info', 'info.employee', 'addons/mymodule/report/employee_info.rml', parser=order, header=False)
report_sxw.report_sxw('report.employee.info1', 'info.employee', 'addons/mymodule/report/employee_info1.rml', parser=order, header=False)
report_sxw.report_sxw('report.employee.info2', 'info.employee', 'addons/mymodule/report/employee_info2.rml', parser=order, header=False)
inside module name
add init.py and openerp.py
init.py
import report
openerp.py
{
'name' : 'Employee Details',
'version' : '7.0',
'author' : '',
'website' : '',
'depends' : ['sale'],
'category' : 'General',
'description' : '''This module contains information about Employee.''',
'update_xml' : [
'wizard/employee_wizard_view.xml',
'employee_info_report.xml', #this is ur rport .xml file
'Employee_info_view.xml'
],
'demo_xml' : []
}
Employee_info_view.xml --------------
<button name="%(employee_wizard_action)d" string="call wizard" type="action"/>
<button name="%(mymodule.report_employee_info)d" string="Click for report" type="action" />
employee_info_report.xml--------
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report auto="False" id="report_employee_info" model="info.employee" name="employee.info" rml="mymodule/report/employee_info.rml" string="Employee info"/>
</data>
</openerp>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký