From 0ad166f5db1df7a3d13b93f1108a82f0ece9a99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Sun, 20 Nov 2022 10:16:00 +0100 Subject: [PATCH] [TMP]pms_api_rest: review input params None/False/'' --- pms_api_rest/services/pms_calendar_service.py | 4 ++-- pms_api_rest/services/pms_invoice_service.py | 4 ++-- pms_api_rest/services/pms_transaction_service.py | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pms_api_rest/services/pms_calendar_service.py b/pms_api_rest/services/pms_calendar_service.py index dda14d1ec..16bc4aa24 100644 --- a/pms_api_rest/services/pms_calendar_service.py +++ b/pms_api_rest/services/pms_calendar_service.py @@ -508,7 +508,7 @@ class PmsCalendarService(Component): reservation_vals.update( {"board_service_room_id": reservation_lines_changes.boardServiceId} ) - if reservation_lines_changes.pricelistId is not None: + if reservation_lines_changes.pricelistId: reservation_vals.update( {"pricelist_id": reservation_lines_changes.pricelistId} ) @@ -518,7 +518,7 @@ class PmsCalendarService(Component): reservation_vals.update( {"children": reservation_lines_changes.children} ) - if reservation_lines_changes.segmentationId is not None: + if reservation_lines_changes.segmentationId: reservation_vals.update( { "segmentation_ids": [ diff --git a/pms_api_rest/services/pms_invoice_service.py b/pms_api_rest/services/pms_invoice_service.py index e493f5c83..7531a8f77 100644 --- a/pms_api_rest/services/pms_invoice_service.py +++ b/pms_api_rest/services/pms_invoice_service.py @@ -33,12 +33,12 @@ class PmsInvoiceService(Component): raise UserError(_("You can't update a reversed invoice")) new_vals = {} if ( - pms_invoice_info.partnerId is not None + pms_invoice_info.partnerId and pms_invoice_info.partnerId != invoice.partner_id.id ): new_vals["partner_id"] = pms_invoice_info.partnerId - if pms_invoice_info.date is not None: + if pms_invoice_info.date: invoice_date_info = fields.Date.from_string(pms_invoice_info.date) if invoice_date_info != invoice.invoice_date: new_vals["invoice_date"] = invoice_date_info diff --git a/pms_api_rest/services/pms_transaction_service.py b/pms_api_rest/services/pms_transaction_service.py index 4b4cf1a5d..473ddcc08 100644 --- a/pms_api_rest/services/pms_transaction_service.py +++ b/pms_api_rest/services/pms_transaction_service.py @@ -315,8 +315,10 @@ class PmsTransactionService(Component): pms_transaction_info.amount, 2 ) != round(transaction.amount, 2): vals["amount"] = pms_transaction_info.amount + # Review: review all input parameters in all services + # to determine the handling of values: False or 0, None, and empty string '' if ( - pms_transaction_info.partnerId is not None + pms_transaction_info.partnerId and pms_transaction_info.partnerId != transaction.partner_id.id ): vals["partner_id"] = pms_transaction_info.partnerId