Skip to Content
Menu
This question has been flagged
2 Replies
13717 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 = {
    'lang':'en_GB',
    }

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

This was what i wanted

Best Answer

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 = {
       'lang':_get_mylang,
}

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

Thanks
Sandeep

Avatar
Discard
Author

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

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']

is this a selection field ??

this will work for money2one relation

Author

yes it is a selection field

all the available language will be seen into that selection field

its actually wrong!! please check it

whats wrong?? , let me know

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

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

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

:-) nothing more to say

Author

thankyou for the help sir

Related Posts Replies Views Activity
2
Feb 23
4870
1
Dec 23
19881
1
Aug 19
5203
1
Apr 25
749
2
Oct 23
4729