From e24210e24eb3f01c3adc7b78b61d054cee858b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Fri, 11 Oct 2024 09:18:55 +0200 Subject: [PATCH] [ADD]pms_api_rest: lastUpdateFrom param in folio and reservation GET --- pms_api_rest/datamodels/pms_folio.py | 1 + pms_api_rest/datamodels/pms_reservation.py | 2 +- pms_api_rest/services/pms_folio_service.py | 6 ++++++ pms_api_rest/services/pms_reservation_service.py | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pms_api_rest/datamodels/pms_folio.py b/pms_api_rest/datamodels/pms_folio.py index df61c1d161..c4dd8dc27e 100644 --- a/pms_api_rest/datamodels/pms_folio.py +++ b/pms_api_rest/datamodels/pms_folio.py @@ -16,6 +16,7 @@ class PmsFolioSearchParam(Datamodel): ids = fields.List(fields.Integer(), required=False) createDateFrom = fields.String(required=False, allow_none=True) createDateTo = fields.String(required=False, allow_none=True) + lastUpdateFrom = fields.String(required=False, allow_none=True) class PmsFolioInfo(Datamodel): diff --git a/pms_api_rest/datamodels/pms_reservation.py b/pms_api_rest/datamodels/pms_reservation.py index c2896e6232..ac00d09ce9 100644 --- a/pms_api_rest/datamodels/pms_reservation.py +++ b/pms_api_rest/datamodels/pms_reservation.py @@ -44,7 +44,7 @@ class PmsReservationShortInfo(Datamodel): reservationType = fields.String(required=False, allow_none=True) segmentationId = fields.Integer(required=False, allow_none=True) isOverNightRoom = fields.Boolean(required=False, allow_none=True) - + lastUpdateFrom = fields.String(required=False, allow_none=True) class PmsReservationInfo(Datamodel): diff --git a/pms_api_rest/services/pms_folio_service.py b/pms_api_rest/services/pms_folio_service.py index 8416341634..bbf5d37554 100644 --- a/pms_api_rest/services/pms_folio_service.py +++ b/pms_api_rest/services/pms_folio_service.py @@ -159,6 +159,12 @@ def get_folios(self, folio_search_param): if folio_search_param.ids: domain_filter.append([("folio_id", "in", folio_search_param.ids)]) + if folio_search_param.lastUpdateFrom: + last_update_from = fields.Datetime.from_string( + folio_search_param.lastUpdateFrom + ) + domain_filter.append([("write_date", ">=", last_update_from)]) + if folio_search_param.filter: target = folio_search_param.filter if "@" in target: diff --git a/pms_api_rest/services/pms_reservation_service.py b/pms_api_rest/services/pms_reservation_service.py index 495396dbbe..41794e9744 100644 --- a/pms_api_rest/services/pms_reservation_service.py +++ b/pms_api_rest/services/pms_reservation_service.py @@ -715,6 +715,9 @@ def get_reservations(self, pms_search_param): ), ) ) + if pms_search_param.lastUpdateFrom: + last_update = fields.Datetime.from_string(pms_search_param.lastUpdateFrom) + domain.append(("write_date", ">=", last_update)) reservations = self.env["pms.reservation"].search(domain) PmsReservationInfo = self.env.datamodels["pms.reservation.info"]