Python 如何创建Openerp报告

Python 如何创建Openerp报告,python,report,openerp,Python,Report,Openerp,我在openerp中有一个简单的模块,我需要该模块的报告。我已经搜索了很多链接,但我不能得到确切的答案。 这里是我的源代码 init.py 开瓶器 sim.py from openerp.osv import fields, osv class student(osv.osv): _name = "sim.student" _description = "This table is for keeping personal data of student" _columns = { 'r

我在openerp中有一个简单的模块,我需要该模块的报告。我已经搜索了很多链接,但我不能得到确切的答案。 这里是我的源代码

init.py

开瓶器

sim.py

from openerp.osv import fields, osv
class student(osv.osv):
_name = "sim.student"
_description = "This table is for keeping personal data of student"
_columns = {
    'reg_no': fields.integer('Registration Number',size=7,required=True),
    'student_name': fields.char('Student Name',size=25,required=True),
    'father_name': fields.char("Father's Name",size=25),
    'gender':fields.selection([('male','Male'),('female','Female')],'Gender'),
    'contact_no':fields.char('Contact Number',size=10),
    'address':fields.char('Address',size=256)
}
_sql_constraints = [
('uniq_name', 'unique(reg_no)', 'This Reg.No is number already registered!') 
]

student()
sim_view.xml

<?xml version="1.0"?>
<openerp>
<data>
<!-- ============== student================= -->
<!-- 1st part of the sim_view start-->
<record model="ir.ui.view" id="student_form">
<field name="name">Student</field>
<field name="model">sim.student</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Student" version="7.0">
<group>
<field name="reg_no"/>
<field name="student_name"/>
<field name="father_name"/>
<field name="gender"/>
<field name="contact_no"/>
<field name="address"/>
</group>
</form>
</field>
</record>
<!-- 1st part of the sim_view end-->

<!--2nd part of the sim_view start-->
<record model="ir.ui.view" id="student_tree">
<field name="name">Student</field>
<field name="model">sim.student</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Student">
<field name="reg_no"/>
<field name="student_name"/>
<field name="father_name"/>
<field name="gender"/>
<field name="contact_no"/>
<field name="address"/>
</tree>
</field>
</record>
<!--2nd part of the sim_view end-->

<!-- 3rd part of the sim_view start-->
<record model="ir.actions.act_window" id="action_student">
<field name="name">Student</field>
<field name="res_model">sim.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!--3rd part of the sim_view end-->

<!--4th part of the sim_view start-->
<menuitem name="SIM/Student/StudentInfo" id="menu_sim_student"  
      action="action_student"/>
<!--4th part of the sim_view end-->
</data>
</openerp>

大学生
模拟学生
类型
大学生
模拟学生
树
大学生
模拟学生
类型
树

该模块工作正常。但我不知道如何为此创建报告。请给出任何答案。

您需要通过sxw、rml和python代码创建报告,还可以从AeroReport和wkhtmltopdf(Webkit报告引擎)创建报告


对于sxw和rml,请查看此链接,这将帮助您很多

查看此链接,这将帮助您。我有ubuntu 14.10,openoffice报表设计器在LibreOffice中不支持。是的,您需要降级libre-office版本,例如,如果您有4.X.X,则需要在3.X.X中降级
from openerp.osv import fields, osv
class student(osv.osv):
_name = "sim.student"
_description = "This table is for keeping personal data of student"
_columns = {
    'reg_no': fields.integer('Registration Number',size=7,required=True),
    'student_name': fields.char('Student Name',size=25,required=True),
    'father_name': fields.char("Father's Name",size=25),
    'gender':fields.selection([('male','Male'),('female','Female')],'Gender'),
    'contact_no':fields.char('Contact Number',size=10),
    'address':fields.char('Address',size=256)
}
_sql_constraints = [
('uniq_name', 'unique(reg_no)', 'This Reg.No is number already registered!') 
]

student()
<?xml version="1.0"?>
<openerp>
<data>
<!-- ============== student================= -->
<!-- 1st part of the sim_view start-->
<record model="ir.ui.view" id="student_form">
<field name="name">Student</field>
<field name="model">sim.student</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Student" version="7.0">
<group>
<field name="reg_no"/>
<field name="student_name"/>
<field name="father_name"/>
<field name="gender"/>
<field name="contact_no"/>
<field name="address"/>
</group>
</form>
</field>
</record>
<!-- 1st part of the sim_view end-->

<!--2nd part of the sim_view start-->
<record model="ir.ui.view" id="student_tree">
<field name="name">Student</field>
<field name="model">sim.student</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Student">
<field name="reg_no"/>
<field name="student_name"/>
<field name="father_name"/>
<field name="gender"/>
<field name="contact_no"/>
<field name="address"/>
</tree>
</field>
</record>
<!--2nd part of the sim_view end-->

<!-- 3rd part of the sim_view start-->
<record model="ir.actions.act_window" id="action_student">
<field name="name">Student</field>
<field name="res_model">sim.student</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!--3rd part of the sim_view end-->

<!--4th part of the sim_view start-->
<menuitem name="SIM/Student/StudentInfo" id="menu_sim_student"  
      action="action_student"/>
<!--4th part of the sim_view end-->
</data>
</openerp>