forked from alaguraj/odoo-testing-addons
implement Uber Direct webhook and quote controllers and update docker-compose service naming
This commit is contained in:
parent
fdd9d4b7f7
commit
511f50f25a
@ -47,9 +47,15 @@ class UberDeliveryController(http.Controller):
|
||||
return {'success': False, 'error': 'Uber not configured'}
|
||||
|
||||
company = request.website.company_id
|
||||
# Build clean pickup address using State CODE (e.g. ON for Ontario)
|
||||
# Build clean pickup address - check for False/None values
|
||||
p_street = company.street or ""
|
||||
p_city = company.city or ""
|
||||
p_state = company.state_id.code or company.state_id.name or ""
|
||||
pickup_address = f"{company.street}, {company.city} {p_state} {company.zip}, {company.country_id.name}"
|
||||
p_zip = company.zip or ""
|
||||
p_country = company.country_id.name or "Canada"
|
||||
|
||||
# Format: "Street, City State Zip, Country"
|
||||
pickup_address = f"{p_street}, {p_city} {p_state} {p_zip}, {p_country}".replace(" ", " ").strip(", ")
|
||||
|
||||
# User entered address
|
||||
street = address_data.get('street', '').strip()
|
||||
@ -57,24 +63,23 @@ class UberDeliveryController(http.Controller):
|
||||
full_street = f"{street}, {street2}" if street2 else street
|
||||
|
||||
# Clean state (Try for code if possible)
|
||||
state_input = address_data.get('state', '').split('(')[0].strip()
|
||||
state_input = (address_data.get('state') or '').split('(')[0].strip()
|
||||
state_record = request.env['res.country.state'].sudo().search([
|
||||
'|', ('name', '=ilike', state_input), ('code', '=ilike', state_input)
|
||||
], limit=1)
|
||||
state_to_send = state_record.code if state_record else state_input
|
||||
|
||||
# Construct dropoff string in exact POS format: "Street, City State Zip, Country"
|
||||
# Construct dropoff string
|
||||
city = address_data.get('city', '').strip()
|
||||
zip_code = address_data.get('zip', '').strip()
|
||||
country = address_data.get('country', 'Canada').strip()
|
||||
# Canada country code is CA
|
||||
country_code = "Canada"
|
||||
|
||||
country_record = request.env['res.country'].sudo().search([
|
||||
'|', ('name', '=ilike', country), ('code', '=ilike', country)
|
||||
], limit=1)
|
||||
if country_record: country_code = country_record.name
|
||||
country_name = country_record.name if country_record else "Canada"
|
||||
|
||||
dropoff_address = f"{full_street}, {city} {state_to_send} {zip_code}, {country_code}"
|
||||
dropoff_address = f"{full_street}, {city} {state_to_send} {zip_code}, {country_name}".replace(" ", " ").strip(", ")
|
||||
|
||||
_logger.info("Uber Direct API Call - Pickup: '%s' | Dropoff: '%s'", pickup_address, dropoff_address)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user