Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
16992 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 19
5355
0
พ.ย. 18
4096
Hide menu for all except specific group แก้ไขแล้ว
1
พ.ย. 22
3252
Live tracking in odoo. แก้ไขแล้ว
2
ส.ค. 22
7588
1
ม.ค. 25
9294