Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5269 Zobrazení

Hi,

How to define default country in webshop checkout form?

Avatar
Zrušit
Nejlepší odpověď

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.
 

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
čvc 16
8806
1
úno 18
12920
1
kvě 16
6124
0
čvn 15
4150
0
kvě 17
9160