如何在OpenERP或Odoo中创建手风琴或子类别视图? [英] How to Create an accordion or subcategories view in OpenERP or Odoo?
本文介绍了如何在OpenERP或Odoo中创建手风琴或子类别视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建手风琴或子类别视图?
Create an accordion or subcategories view?
我正在尝试从product.category视图创建一个手风琴视图.
I'm trying to create an accordion view from product.category view.
我希望所有类别都在顶部,如果其中任何一个有孩子,我希望它们在手风琴列表中或带有子类别.
I want all the categories at top and if any of them have childs I want them in a accordion list or with subcategories.
例如:
-
所有/购买/主席/C88
All/Purchase/Chairs/C88
-
全部
-
购买
-
椅子
- C88
我想要这个与产品类别
谢谢
推荐答案
Let's use the bootstrap accordion (https://getbootstrap.com/docs/4.0/components/collapse/), for instance : for products belonging to category_2 included in category_1 :
<template id="products_categories_nested_accordions" inherit_id="website_sale.products_categories" active="False" customize_show="True" name="eCommerce Categories">
<xpath expr="//div[@id='products_grid_before']" position="inside">
<a href="#" role="button" class="collapsed" data-toggle="collapse" t-attf-data-target=".#{category_1.name}" t-attf-data="#{category_1.name}" aria-expanded="false">
<span class="fa fa-plus pull-right"/>
<label t-field="category_1.name" />
</a>
<t t-foreach="category_1.categories_2_ids" t-as="category_2">
<div t-attf-class=" collapse #{category_1.name} "
t-attf-data="#{category_2.name}" >
<a href="#" role="button" class="collapsed" data-toggle="collapse" t-attf-data-target=".#{category_2.name}" t-attf-data="#{category_2.name}" aria-expanded="false">
<span class="fa fa-plus pull-right"/>
<label t-field="category_2.name" />
</a>
</div>
<t t-foreach="products" t-as="product">
<div t-attf-class=" collapse #{category_2.name} "
t-attf-data="#{product.name}" >
<span itemprop="name" t-field="product.name" class="my-0" />
</div>
</t>
</t>
</xpath>
</template>
以此类推,彼此之间还有其他嵌套类别...
And so on with other nested categories in each other...
这篇关于如何在OpenERP或Odoo中创建手风琴或子类别视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文