Odoo Help


How to set default language in res_partner.py

on 5/24/13, 6:36 AM 3,235 views

I have defined a new language named English-India and its code is en_GB and I want to get this language as default set on language field when a customer and user is created.I overridden res_users.py and res_partner.py and I gave the following code to _defaults of res_users and `res_partner.

_defaults = {

In user creation the language field is English-India by default but its not working in customer creation. Can some one help?


Omal Bastin

--Omal Bastin--
| 6 6 8
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

Omal Bastin
On 5/24/13, 8:53 AM

Hi, Goto Settings > Technical > Actions > User defined Defaults, there you can find that default value is set as en_US, you can delete this record or change it to your language

This was what i wanted

on 6/18/13, 5:22 AM


| 6 5 8
Delhi, India
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
On 5/24/13, 8:39 AM

Hey Pravitha

DO it as below :

inherit your res.partner

and add this new function in that class (res_partner)

   def _get_mylang(self, cr, uid, context=None):
         ids = self.pool.get('res.lang').search(cr, uid, [], context=context)
         res = self.pool.get('res.lang').read(cr, uid, ids, ['code', 'name'], context)     
         return [(j['code'], j['name']) for j in res] + [('','')]

and then just add this method in _defauts link below

   _defaults = {

or also you can go through -- > Settings > Technical > Actions > User defined Defaults thats it


Helo sir, Thankyou for the reply . can i ask you somthing will it show english also in the selection?

on 5/24/13, 8:52 AM

Hi, your function will only return the id of the language. then lang field is actually a selection. So the function should be like def _lang_get(self, cr, uid, context=None): lang_pool = self.pool.get('res.lang') ids = lang_pool.search(cr, uid, [('code','=','en_GB')], context=context) res = lang_pool.read(cr, uid, ids, ['code'], context) return r['code']

Omal Bastin
on 5/24/13, 8:57 AM

is this a selection field ??

on 5/24/13, 9:06 AM

this will work for money2one relation

on 5/24/13, 9:07 AM

yes it is a selection field

on 5/24/13, 9:11 AM

see updated answer now

on 5/24/13, 9:14 AM

all the available language will be seen into that selection field

on 5/24/13, 9:15 AM

its actually wrong!! please check it

Omal Bastin
on 5/24/13, 9:18 AM

whats wrong?? , let me know

on 5/24/13, 9:22 AM

man, it should not be wrong .......:))

on 5/24/13, 9:30 AM

your _get_mylang will return a list of tuples. To get a default value, you need to pass the key value of the selection list. jou just check it in your local server

Omal Bastin
on 5/24/13, 10:02 AM

oh man it is fine .:):) and for your information ,, selection gets tuple value with (key,value)

on 5/24/13, 10:03 AM

:-) nothing more to say

Omal Bastin
on 5/24/13, 10:08 AM

thankyou for the help sir

on 6/18/13, 5:21 AM

ok that's fine

on 6/18/13, 5:30 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 5/24/13, 6:36 AM
Seen: 3235 times
Last updated: 2/29/16, 11:17 AM