Skip to content

Commit

Permalink
[REF] api: Optimize address update condition in create_address
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JAntonioSalas committed May 23, 2024
1 parent 9eaa429 commit f49eb3a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions hantec_api_ecommerce/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f49eb3a

Please sign in to comment.