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

Odoo version 11.0

Currently, i got product by filter like,

lafilter[0] = new object[3] { "type", "=", "product" };

- and also i want to add one more filter for get unique record, like "distinct by Id" 

any idea about "distinct" record ?

Thanks 

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

Hi, 

You can group by that field by calling read_group function, for example:

result = self.env['yourmodel'].read_group([ ("type", "=", "product") ], fields=['Id'], groupby=['Id'])


PS: if you liked the answer - please upvote it :)

الصورة الرمزية
إهمال

Awesome!!!

أفضل إجابة

if you are working in JavaScript here is the rpc query


                    rpc.query({
model: 'sale.report',
method: 'read_group',
fields: ['price_subtotal:sum'],
kwargs: {groupby: 'date:year'},
lazy: false,
}).then(function (result) {
console.log(result)
});

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

Hello

I used read_group like this.

But without orderby=False then 'ORDER BY "id" is ambiguous' or

with orderby=['id'] then 'TypeError: expected string or bytes-like object'

How can I use it?

الصورة الرمزية
إهمال

I changed with orderby='name' is working

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 19
5365
0
نوفمبر 18
4098
1
نوفمبر 22
3252
2
أغسطس 22
7589
1
يناير 25
9299