From f49eb3a3ef5c16b70823254ec8c5cf6defa7a8bb Mon Sep 17 00:00:00 2001 From: "DESKTOP-IQ6LM3K\\Jose Antonio" Date: Thu, 23 May 2024 09:45:37 -0600 Subject: [PATCH] [REF] api: Optimize address update condition in create_address The code now combines the condition 'only_create' and 'address' into a single line, ensuring that an address is only updated if it exists and it is not flagged with the 'only_create' option. This change makes the code easier to read and understand. Closes #25 --- hantec_api_ecommerce/controllers/main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hantec_api_ecommerce/controllers/main.py b/hantec_api_ecommerce/controllers/main.py index 80cc012..5d8ad45 100644 --- a/hantec_api_ecommerce/controllers/main.py +++ b/hantec_api_ecommerce/controllers/main.py @@ -149,9 +149,7 @@ def create_address(self): [("parent_id", "=", partner_id), ("type", "=", address_type)], limit=1 ) - if only_create: - address = False - if address: + if address and not only_create: # Update existing address address.write(address_data) else: