【发布时间】:2016-06-09 08:44:55
【问题描述】:
我正在尝试使用分层视图为产品类别创建自己的自定义模块。
我的主要要求是能够创建具有折叠、展开功能的视图。
这是一个例子:
|类别根目录(展开)
|Category A (UNFolded)
|Sub Category A1
|Category B (UnFolded)
|Sub Category B1
|Sub Category B2
|Sub Category B3
|Category C (Folded)
如果我点击类别 C 行,我将能够展开它并查看它的子类别。
我尝试了以下方法: 对于班级
class odepoCategory(models.Model):
_name = 'odepo.category'
name = fields.Char(string='Nom Category')
parentCategory = fields.Many2one('odepo.category', string='Categorie Pére', select=True, ondelete='cascade')
subCategories = fields.One2many('odepo.category', 'name', string='Sous Categories')
为了风景
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="enquiry_tree_view_leads">
<field name="name">view.enquiry.leads.tree</field>
<field name="model">odepo.category</field>
<field name="field_parent">subCategories</field>
<field name="arch" type="xml">
<tree toolbar="True" string="Enquiry Leads">
</tree>
</field>
</record>
<record model="ir.ui.view" id="enquiry_tree_view_leads">
<field name="name">view.enquiry.leads.form</field>
<field name="model">odepo.category</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Shipping Information">
<group>
<field name="parentCategory"/>
<field name="name"/>
<!-- <field name="subCategories"/> -->
</group>
</form>
</field>
</record>
<record id="product_category_action" model="ir.actions.act_window">
<field name="name">Products by Category</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">odepo.category</field>
<field name="domain">[('parentCategory','=',False)]</field>
<field name="view_type">tree</field>
<field name="help" type="html">
<p>
Here is a list of all your products classified by category. You
can click a category to get the list of all products linked to
this category or to a child of this category.
</p>
</field>
</record>
<!-- Action to open To-do Task list -->
<act_window id="action_todo_task"
name="To-do Task"
res_model="odepo.category"
view_mode="tree,form" />
<!-- Menu item to open To-do Task list -->
<menuitem id="menu _todo_task"
name="To-Do Tasks"
parent="mail.mail_feeds"
sequence="20"
action="action_todo_task" />
</data>
</openerp>
但是我不知道如何显示分层视图。
【问题讨论】:
-
您正在寻找后端或网站
-
Nope.Actually 我正在创建没有继承的自定义产品类别。该模型正在工作。只有视图不起作用。所有类别都显示为通常的 VIew,而不是分层视图。我知道域过滤器是解决方案,但它不适合我
标签: view odoo-8 hierarchical