我创建了一个自定义模块,以将Excel文件中的数据作为表格导入。导入后,我注意到列表视图的行包含数据,但是当我切换到图形视图(更确切地说是在数据透视图视图中)时,我发现该表仍然为空,其中没有数据。我已经被这个问题困扰了好几天了。我不知道该怎么办。有什么帮助吗?
salary_table_view.xml
<!-- Salary Table -->
<!-- salary_table tree view -->
<record id="salary_table_tree_view" model="ir.ui.view">
<field name="name">Salary Table Tree View</field>
<field name="model">salary.table</field>
<field name="arch" type="xml">
<tree>
<field name="Degree"/>
<field name="Categorie_11"/>
<field name="Categorie_12"/>
<field name="Categorie_13"/>
<field name="Categorie_21"/>
<field name="Categorie_22"/>
<field name="Categorie_23"/>
<field name="Categorie_31"/>
<field name="Categorie_32"/>
<field name="Categorie_33"/>
<field name="Categorie_41"/>
<field name="Categorie_42"/>
<field name="Categorie_43"/>
</tree>
</field>
</record>
<!-- salary_table graph view -->
<record id="salary_table_graph_view" model="ir.ui.view">
<field name="name">Salary Table Graph View</field>
<field name="model">salary.table</field>
<field name="arch" type="xml">
<graph>
<field name="Degree" type="row"/>
</graph>
</field>
</record>
<!-- salary_table Pivot view -->
<record id="salary_table_pivot_view" model="ir.ui.view">
<field name="name">Salary Table Pivot View</field>
<field name="model">salary.table</field>
<field name="arch" type="xml">
<graph string="convention" type="pivot">
<field name="Categorie_11" type="measure"/>
<field name="Categorie_12" type="measure"/>
<field name="Categorie_13" type="measure"/>
<field name="Categorie_21" type="measure"/>
<field name="Categorie_22" type="measure"/>
<field name="Categorie_23" type="measure"/>
<field name="Categorie_31" type="measure"/>
<field name="Categorie_32" type="measure"/>
<field name="Categorie_33" type="measure"/>
<field name="Categorie_41" type="measure"/>
<field name="Categorie_42" type="measure"/>
<field name="Categorie_43" type="measure"/>
<field name="Degree" type="row"/>
</graph>
</field>
</record>
<!-- salary_table Action -->
<record model="ir.actions.act_window" id="salary_table_action">
<field name="name">Salary Table</field>
<field name="res_model">salary.table</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree,form</field>
</record>
<!-- salary table menu item -->
<menuitem id="salary_table_menu" action="salary_table_action" parent="hr.menu_hr_configuration" sequence="0" />
</data>
salary_table.py
from openerp import fields,osv, models
class salary_table(models.Model):
_name = 'salary.table'
Degree = fields.Char(string="Degree")
Categorie_11 = fields.Float(string="Categorie_11")
Categorie_12 = fields.Float(string="Categorie_12")
Categorie_13 = fields.Float(string="Categorie_13")
Categorie_21 = fields.Float(string="Categorie_21")
Categorie_22 = fields.Float(string="Categorie_22")
Categorie_23 = fields.Float(string="Categorie_23")
Categorie_31 = fields.Float(string="Categorie_31")
Categorie_32 = fields.Float(string="Categorie_32")
Categorie_33 = fields.Float(string="Categorie_33")
Categorie_41 = fields.Float(string="Categorie_41")
Categorie_42 = fields.Float(string="Categorie_42")
Categorie_43 = fields.Float(string="Categorie_43")