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

Hi,

I am a bit lost. I am trying to translate my module to V8, but can't find the way to translate the following statement:

self.pool.get('some_model').search(cr, uid, [('cols', '=', hotel)], context=context)

I found out that the search works like this:

self.search([('is_company', '=', True), ('customer', '=', True)])

but can't find how to get the external model first (self.pool.get).

Any tip on where to look will be appreciated! Thanks!

 

الصورة الرمزية
إهمال
أفضل إجابة

In new api you can search your domain directly like

self.search([(’is_company’, ’=’, True)])

will return record set

    >> model.model(1,2,3,4)

It will return direct record set.

In the new API the notion of Environment is introduced. Its main objective is to provide an encapsulation around
cursor, user_id, model, and context, Recordset and caches.

If you wanted to search another object's record

user_env = self.env[’res.users’]
user_env.search([(’login’, ’=’, ’atul’)])

    
will return record set

    >>res.users(9,)

الصورة الرمزية
إهمال
الكاتب

Thanks Atui! the self.env part was the one I was missing. Thank you

أفضل إجابة

Hi yakito,

you can search anything from external model by using this code:

self.env['res.partner'].search([['is_company', '=', True], ['customer', '=', True]])

 

Try this..

الصورة الرمزية
إهمال
الكاتب

Thanks a lot Vasanth!

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مايو 15
4067
0
مارس 15
7317
3
أغسطس 15
7025
0
أبريل 15
4050
2
مارس 15
8079