Mohammed Shekha(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-client-web/6.0-opw-20039-msh into 
lp:openobject-client-web.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-20039-msh/+merge/84238

Hello,

Fixed the issue of language configuration when there are multiple user using 
the system with same database but with different language.

Demo:- To generate this problem on local system you need two user in the 
Database and both the user must use different locale with different language 
configuration of decimal point and thousand separator. You also need two 
browser to use the same db with different user.

Now open first browser and login with user1 who is using language say foe e.g. 
en_us,and open any list view which is showing float value.

Now open second browser and login with user2 who is using language say for e.g. 
en_gb,

Now go to first browser and just refresh the page you will see the locale 
configuration of user2 will be applied in user1.

Reason :- Here we have not used language configuration of session but instead 
of it we were set by calling set_locale_cache in rpc.py, so the language 
configuration of user2 will overwrite the language configuration of user1.

So changed the code accordingly and used session language configuration so that 
problem not raised.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-20039-msh/+merge/84238
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-client-web/6.0-opw-20039-msh.
=== modified file 'addons/openerp/utils/rpc.py'
--- addons/openerp/utils/rpc.py	2011-09-15 11:09:44 +0000
+++ addons/openerp/utils/rpc.py	2011-12-02 10:54:25 +0000
@@ -350,8 +350,6 @@
         if lang_ids:
             self.storage['lang'] = self.execute(
                     'object', 'execute', 'res.lang', 'read', lang_ids[0], [])
-            lang_data = self.storage['lang']
-            format.set_locale_cache(lang_data)
 
     def execute(self, obj, method, *args):
         if not self.is_logged():

=== modified file 'openobject/i18n/format.py'
--- openobject/i18n/format.py	2011-09-15 11:09:44 +0000
+++ openobject/i18n/format.py	2011-12-02 10:54:25 +0000
@@ -290,23 +290,16 @@
 
     return fixed_domain
 
-LOCALE_CACHE = {
-               'date_format':'%m/%d/%Y',
-               'time_format':'%H:%M:%S',
-               'grouping':[],
-               'decimal_point':'.',
-               'thousands_sep': ','
-                }
 
 def get_lang_float_format(locale_lang,monetary=False):
-    thousands_sep = LOCALE_CACHE.get('thousands_sep') or numbers.get_group_symbol(locale_lang)
-    decimal_point = LOCALE_CACHE.get('decimal_point')
-    grouping      = LOCALE_CACHE.get('grouping')
+    thousands_sep = cherrypy.session['lang'].get('thousands_sep') or numbers.get_group_symbol(locale_lang)
+    decimal_point = cherrypy.session['lang'].get('decimal_point')
+    grouping      = cherrypy.session['lang'].get('grouping')
     return (grouping, thousands_sep, decimal_point)
 
 
 def format_decimal(value, digits=2, grouping=True, monetary=False):
-    locale = get_locale()
+    locale = cherrypy.session['lang'].get('code') or get_locale()
     formatted = ("%%.%df" % digits) % value
     lang_grouping, thousands_sep, decimal_point = get_lang_float_format(locale,monetary=False)
     
@@ -376,19 +369,9 @@
     return result + spaces, seps         
         
 
-def set_locale_cache(lang_data={}):
-    try:
-        if lang_data:
-            if 'id' in lang_data:
-                del lang_data['id']
-            LOCALE_CACHE.update(lang_data)
-    except:
-        pass
-
-    
 def parse_decimal(value):
     
-    locale = get_locale()
+    locale = cherrypy.session['lang'].get('code') or get_locale()
     if isinstance(value, basestring):
         
         value = ustr(value)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to