跳至内容
菜单
此问题已终结


I have one model of the category with a child-parent relationship with itself.


class product_public_cate (models.Model):
    _name = "product.public.category"     parent_id = fields.Many2one ('product.public.category', 'parent category')


with many levels of child records, I want the main category and first child of the main category in the controller so fire a search method as below:

request.env ['product.public.category'].  search (['|', ('parent_id.parent_id', '=', False), ('parent_id', '=', False)], order = "parent_id desc")


It gives only the first child of the main category, not all main categories  

as I think there is some problem while comparing domain a parent_id.parent_id = false  
while there is no any parent_id.parent_id for main categories   

so wanted to know why this is happening ?  why I didn't get the main categories in the result is that a domain problem? 

thanks in advance.  



here are some queries that also I try but didn't get a result

request.env ['product.public.category']. search (['|', ('parent_id', '=', False), '&', ('parent_id', '! =', False), ('parent_id.parent_id', '=', False)] , order = "parent_id desc")


for 3 level child 
request.env ['product.public.category']. search (['!', ('parent_id.parent_id.parent_id', '=', False)])


形象
丢弃
相关帖文 回复 查看 活动
1
11月 23
2256
0
9月 18
3246
0
10月 17
9975
2
7月 24
10278
1
12月 23
8866