Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4917 Lượt xem

Hi,

How to define default country in webshop checkout form?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.
 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Nested tree view Đã xử lý
2
thg 7 16
8348
1
thg 2 18
12501
1
thg 5 16
5708
0
thg 6 15
3758
0
thg 5 17
8583