我必須在Odoo10中爲我的模型創建一個層次結構視圖。我做了以下。但我可以得到它。我希望這看起來像odoo8賬戶視圖的圖表。Odoo10層次視圖
pyhon文件:
class InconceExpenseDetails(models.Model):
_name = "income.expense.details"
parent_id = fields.Many2one("income.expense.details","Income ID")
child_ids = fields.One2many("income.expense.details","parent_id",string="Income IDS",select=True)
product_category = fields.Char("Category")
planned_amount = fields.Float('Planned Amount', digits=0)
actual_amount = fields.Float('Actual Amount', digits=0)
variance = fields.Float('Variance', digits=0)
currency_id = fields.Many2one('res.currency', string="Currency", default=lambda self: self.env.user.company_id.currency_id)
company_id = fields.Many2one("res.company",string="Company",default=lambda self: self.env.user.company_id)
type_seq = fields.Char("Sequence", select=1)
type = fields.Selection([
('revenue', 'Revenue'),
('income', 'Income'),
('expense', 'Expense'),
], string="Type")
視圖文件:
<record id="view_budget_tree_view" model="ir.ui.view">
<field name="name">income.expense.details.tree</field>
<field name="model">income.expense.details</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree colors="blue:type == 'income'" string="Income and Expense Details" toolbar="1">
<field name="type_seq"/>
<field name="type"/>
<field name="product_category"/>
<field name="planned_amount"/>
<field name="actual_amount"/>
<field name="variance"/>
<field name="currency_id"/>
<field name="company_id"/>
<field name="parent_id" invisible="1"/>
</tree>
</field>
</record>
法案窗口:
<record id="action_budget_tree_view" model="ir.actions.act_window">
<field name="name">income.expense.details.tree</field>
<field name="res_model">income.expense.details</field>
<field name="view_type">tree</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_id" ref="view_budget_tree_view"/>
</record>
如果我讓它正常樹查看它工作正常。但我想這是層次視圖,因爲它在Odoo8