我正在尝试从Company's Structure
重新创建Odoo
视图。
我已根据model
样本创建了parent_id
child_ids
和res.company
。
但它没有用。这是我的XML
<record id="open_module_tree_my_department_my" model="ir.actions.act_window">
<field name="name">My Department</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">my.department</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
</record>
这是我的model
class MyDepartment(models.Model):
_name = 'my.department'
_description = 'My Department'
name = fields.Char(string="My Department", required=True)
parent_id = fields.Many2one("my.department", "Parent Department", select=True)
child_ids = fields.One2many("my.department", "parent_id", string="Children")
我错过了什么?
答案 0 :(得分:1)
原来我只需要为view
model
<record id="view_my_department_list" model="ir.ui.view">
<field name="name">my.department.tree</field>
<field name="model">my.department</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="My Departments">
<field name="name"/>
<field name="parent_id" invisible="1"/>
</tree>
</field>
</record>
<record id="open_module_tree_my_department_my" model="ir.actions.act_window">
<field name="name">My Department</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">my.department</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_my_department_list"/>
</record>
答案 1 :(得分:0)
@strike_noir 据我所知,从Odoo 11中删除了“ field_parent”,您对odoo11 +中的分层树视图有何其他适应措施?
谢谢。