[FIX] website_sale: checkout: do not reset address country every time

Once the value is set it can be modified by the user
(e.g. if geoip detection was wrong), so should not be reset.
This commit is contained in:
Olivier Dony 2014-09-30 17:54:25 +02:00
parent a1eacb9054
commit 59f77103cc
1 changed files with 6 additions and 5 deletions

View File

@ -406,11 +406,12 @@ class website_sale(http.Controller):
checkout['shipping_id'] = shipping_id
# Default search by user country
country_code = request.session['geoip'].get('country_code')
if country_code:
country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context)
if country_ids:
checkout['country_id'] = country_ids[0]
if not checkout.get('country_id'):
country_code = request.session['geoip'].get('country_code')
if country_code:
country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context)
if country_ids:
checkout['country_id'] = country_ids[0]
values = {
'countries': countries,