~openerp/openobject-client/trunk

« back to all changes in this revision

Viewing changes to bin/rpc.py

[MERGE] user locale to server side defined locale

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import common
30
30
import options
31
31
import os
32
 
 
 
32
import tools
 
33
from tools import user_locale_format
33
34
import re
34
35
 
35
36
CONCURRENCY_CHECK_FIELD = '__last_update'
310
311
        if 'lang' in self.context:
311
312
            import translate
312
313
            translate.setlang(self.context['lang'])
313
 
            options.options['client.lang']=self.context['lang']
314
 
            ids = self.rpc_exec_auth('/object', 'execute', 'res.lang', 'search', [('code', '=', self.context['lang'])])
315
 
            if ids:
316
 
                l = self.rpc_exec_auth('/object', 'execute', 'res.lang', 'read', ids, ['direction'])
317
 
                if l and 'direction' in l[0]:
318
 
                    common.DIRECTION = l[0]['direction']
 
314
            options.options['client.lang'] = self.context['lang']
 
315
            lang_ids = self.rpc_exec_auth('/object', 'execute', 'res.lang', 'search', [('code', '=', self.context['lang'])])
 
316
            if lang_ids:
 
317
                lang_data = self.rpc_exec_auth('/object', 'execute', 'res.lang', 'read', lang_ids, ['date_format', 'time_format', 'grouping', 'decimal_point', 'thousands_sep','direction'])
 
318
                if lang_data and 'direction' in lang_data[0]:
 
319
                    common.DIRECTION = lang_data[0]['direction']
319
320
                    import gtk
320
321
                    if common.DIRECTION == 'rtl':
321
322
                        gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
322
323
                    else:
323
324
                        gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR)
 
325
                tools.user_locale_format.set_locale_cache(lang_data and lang_data[0] or {})
 
326
 
324
327
        if self.context.get('tz'):
325
328
            # FIXME: Timezone handling
326
329
            #   rpc_session.timezone contains the server's idea of its timezone (from time.tzname[0]),
334
337
                # Time values will be displayed as if located in the server timezone. (nothing we can do)
335
338
                pass
336
339
 
337
 
 
338
340
    def logged(self):
339
341
        return self._open
340
342