ORM in odoo framework

Question:

How to change the below sql query to ODOO orm

select max(dnddate) from ink where id = 23 and type= 'h' and kar not in ("5") group by customer;

Asked By: user13416491

||

Answers:

To create your query using Odoo ORM, we should use the read_group function.

inks = self.env['ink'].read_group([
            ('id', '=', 23),
            ('type', '=', 'h'),
            ('kar', 'not in', ("5"))], ['dnddate:max'], ['customer'])

Read about Model.read_group()

https://www.odoo.com/documentation/13.0/reference/orm.html#search-read

Answered By: Paxmees
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.