콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다


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
2407
0
9월 18
3401
0
10월 17
10120
2
7월 24
10404
1
12월 23
8993