【问题标题】:How do I list sub categories of the current ecommerce category in Odoo?如何在 Odoo 中列出当前电子商务类别的子类别?
【发布时间】:2019-06-15 17:10:49
【问题描述】:

在 Odoo(qweb 模板)中,我找不到如何列出活跃的电子商务类别的子类别。有一个默认的“递归”类别列表代码,但我看不到任何代码来简单地列出用户当前类别的 child.id 类别。我正在尝试制作一个子类别标题列表,以便人们深入了解他们想要的内容。我是 qweb 的新手,仅供参考。

这是递归类别列表代码:

<?xml version="1.0"?>
<t name="Collapse Category Recursive" t-name="website_sale.option_collapse_categories_recursive">
    <li class="nav-item">
        <i t-if="categ.child_id" t-attf-class="text-primary fa #{'fa-chevron-down' if categ.id in parent_category_ids else 'fa-chevron-right'}" t-attf-title="#{'Unfold' if categ.id in parent_category_ids else 'Fold'}" t-attf-aria-label="#{'Unfold' if categ.id in parent_category_ids else 'Fold'}" role="img"/>
        <a t-att-href="keep('/shop/category/' + slug(categ), category=0)" t-attf-class="nav-link#{' active' if categ.id == int(category or 0) else ''}" t-field="categ.name"/>
        <ul t-if="categ.child_id" class="nav nav-pills flex-column nav-hierarchy" t-att-style="'display:block;' if categ.id in parent_category_ids else 'display:none;'">
            <t t-foreach="categ.child_id" t-as="categ">
                <t t-if="not search or categ.id in search_categories_ids">
                    <t t-call="website_sale.option_collapse_categories_recursive"/>
                </t>
            </t>
        </ul>
    </li>
</t>

我试图基本上做相反的事情,只显示当前“categ.id”的子猫是什么。

例如:如果“categ.id”具有“categ.child_id”,则在列表中遍历它们。

任何指向现有代码的指针或链接都会非常有帮助。

谢谢!

作为旁注,列出子目录不是像标准电子商务一样吗?我很惊讶这在 odoo 中并不正常。

【问题讨论】:

    标签: odoo qweb odoo-12


    【解决方案1】:

    想通了。在 Odoo Studio 中,创建一个相关的一对多字段,即类别子项。

    然后这个:

    <t t-if="category">
       <t t-foreach="category.x_studio_children" t-as="v">
              <t t-if="category.x_studio_children">
                <span t-field="v.name"/> 
              </t>
            </t>
    </t>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 2020-01-06
      • 1970-01-01
      • 2012-10-12
      • 2018-08-19
      • 1970-01-01
      相关资源
      最近更新 更多