تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2881 أدوات العرض


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
نوفمبر 23
2253
0
سبتمبر 18
3244
0
أكتوبر 17
9938
2
يوليو 24
10276
1
ديسمبر 23
8861