Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

default country in webshop checkout form

By
Jānis
on 11/18/14, 4:00 PM 1,076 views

Hi,

How to define default country in webshop checkout form?

0
Denys
On 1/1/15, 6:49 PM

In file /usr/lib/python2.7/dist-packages/openerp/addons/website_sale/controllers/main.py
find strings
        # Default search by user country
        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]

than, if you wan to "hardcode" default contry, do somthing like this

        # Default search by user country
        if not checkout.get('country_id'):
            checkout['country_id'] = 231 #hardcode Ukraine #country_ids[0]
            #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]

Other country id`s you can find in database
SELECT *   FROM res_country;

Also you must understand that this is a dirty hack and it will disapeared after yuo update odoo.
 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/18/14, 4:00 PM
Seen: 1076 times
Last updated: 3/16/15, 8:10 AM