From bedded878c7fe7fc7ab9607a2d0d1b1281a483ca Mon Sep 17 00:00:00 2001 From: Pieter Bruining Date: Thu, 29 Aug 2024 11:47:24 +0200 Subject: [PATCH 1/2] Offset for searching to be able to paginate though the results --- src/controllers/odoo.crud.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/odoo.crud.ts b/src/controllers/odoo.crud.ts index 7191ddc..fa4dfd5 100644 --- a/src/controllers/odoo.crud.ts +++ b/src/controllers/odoo.crud.ts @@ -43,13 +43,13 @@ export class OdooCRUD { }); } - public searchRead(query: any[], limit = 10): Promise { + public searchRead(query: any[], limit = 10, offset = 0): Promise { return new Promise((resolve, reject) => { const params: any[] = [ this._model, "search_read", [query], - { fields: this._keys, limit: limit } + { fields: this._keys, limit: limit, offset: offset } ]; this._odoo .callRPC(params) From 21d568d6f3af48b0b397d37e24a48c021e63306a Mon Sep 17 00:00:00 2001 From: Pieter Bruining Date: Thu, 29 Aug 2024 12:52:26 +0200 Subject: [PATCH 2/2] Ability to count the items and therefor pages --- src/controllers/odoo.crud.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/odoo.crud.ts b/src/controllers/odoo.crud.ts index fa4dfd5..6f6e7cd 100644 --- a/src/controllers/odoo.crud.ts +++ b/src/controllers/odoo.crud.ts @@ -19,9 +19,9 @@ export class OdooCRUD { this._keys = keys; } - public count(): Promise { + public count(query: any[]): Promise { return new Promise((resolve, reject) => { - const params: any[] = [this._model, "search_count", [[]]]; + const params: any[] = [this._model, "search_count", [query]]; this._odoo .callRPC(params) .then((value: any) => {