コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5715 ビュー

Hello there, i want to display categories menu inside my products, so i'm using this code in the product view

<div class="col-md-2 bg-700">
<ul class="nav nav-pills flex-column mt16">
<li class="nav-item">
<a t-att-href="keep('/shop/',category=0)" >All Products</a>
</li>
<t t-foreach="categories" t-as="c" >
<t t-call="website_sale.categories_recursive"/>
</t>
</ul>
</div>


That works but THERE IS A PROBLEM, when i search a product using the search button and open the product i get an Error

 ------------------

argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/addons/base/models/qweb.py", line 347, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_website_sale_categories_recursive_104
  File "<template>", line 7, in foreach_103
TypeError: argument of type 'NoneType' is not iterable

Error to render compiling AST
TypeError: argument of type 'NoneType' is not iterable
Template: website_sale.categories_recursive
Path: /templates/t/li/ul/t/t
Node: <t t-if="not search or c.id in search_categories_ids">
                        <t t-call="website_sale.categories_recursive"/>
                    </t>

----------------------------------------------------

アバター
破棄
最善の回答

Hi, 

Your XML code is correct but you are missing to fetch all 'categories' in controller. 

You have to fetch categories in product page. Like shop controller fetch all 'categories'. Exactly same you have to fetch and render. 

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
0
4月 16
3040
1
3月 15
1012
0
3月 15
3048
1
1月 25
1962
0
11月 24
1004