summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerome hanke (jhk) <jhk@odoo.com>2020-04-09 13:03:22 +0000
committerjerome hanke (jhk) <jhk@odoo.com>2020-04-23 10:20:29 +0000
commitb4ba1ccb1382e402f333a155c4fbda35a360ca64 (patch)
tree4a3223360526999b7007a1d58a3468af332a6172
parent6ff823b2f635db8bb0fbcc4f7c17578335176d9e (diff)
[FIX] website_crm: state_id=false not shown in lead description
Steps to reproduce: - install website, crm - go to crm > settings > activate leads - add a contact form to your website and submit - go to the created lead Previous behavior: state_id is shown as false when geoip data is empty Current behavior: state_id is not shown if geoip is if the state found in geoip does not not exist on the Odoo instance opw-2218498 closes odoo/odoo#50055 X-original-commit: eba0eafac78adb498f8062f3490cea0847ed7927 Signed-off-by: mightyjol <jhk-odoo@users.noreply.github.com>
-rw-r--r--addons/website_crm/controllers/main.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/website_crm/controllers/main.py b/addons/website_crm/controllers/main.py
index 2347d4aa838..33687e221fc 100644
--- a/addons/website_crm/controllers/main.py
+++ b/addons/website_crm/controllers/main.py
@@ -43,9 +43,9 @@ class WebsiteForm(WebsiteForm):
geoip_country_code = request.session.get('geoip', {}).get('country_code')
geoip_state_code = request.session.get('geoip', {}).get('region')
if geoip_country_code and geoip_state_code:
- State = request.env['res.country.state']
- request.params['state_id'] = State.search([('code', '=', geoip_state_code), ('country_id.code', '=', geoip_country_code)]).id
-
+ state = request.env['res.country.state'].search([('code', '=', geoip_state_code), ('country_id.code', '=', geoip_country_code)])
+ if state:
+ request.params['state_id'] = state.id
return super(WebsiteForm, self).website_form(model_name, **kwargs)
def insert_record(self, request, model, values, custom, meta=None):