diff options
| author | YSA (Openerp) <ysa@tinyerp.com> | 2011-01-20 11:07:33 +0530 |
|---|---|---|
| committer | YSA (Openerp) <ysa@tinyerp.com> | 2011-01-20 11:07:33 +0530 |
| commit | f030d1219e2411e4b557f960d603fca1fcbb012e (patch) | |
| tree | f7cc7e772563e2a1fecc9713987b569af35bd0d4 /bin/tools | |
| parent | 1b287f9b7b7ffc6719a7839753597341cc75d7fb (diff) | |
| parent | 10a6bb350c2f054e262ee4649855185795e611d5 (diff) | |
Merge with trunk-server
bzr revid: ysa@tinyerp.com-20110120053733-ws7mfcfw15p0iyy1
Diffstat (limited to 'bin/tools')
| -rw-r--r-- | bin/tools/misc.py | 45 | ||||
| -rw-r--r-- | bin/tools/translate.py | 13 |
2 files changed, 54 insertions, 4 deletions
diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 015299bcf05..d18090932dc 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -1352,6 +1352,51 @@ DEFAULT_SERVER_DATETIME_FORMAT = "%s %s" % ( DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_TIME_FORMAT) +# Python's strftime supports only the format directives +# that are available on the platform's libc, so in order to +# be cross-platform we map to the directives required by +# the C standard (1989 version), always available on platforms +# with a C standard implementation. +DATETIME_FORMATS_MAP = { + '%C': '', # century + '%D': '%m/%d/%Y', # modified %y->%Y + '%e': '%d', + '%E': '', # special modifier + '%F': '%Y-%m-%d', + '%g': '%Y', # modified %y->%Y + '%G': '%Y', + '%h': '%b', + '%k': '%H', + '%l': '%I', + '%n': '\n', + '%O': '', # special modifier + '%P': '%p', + '%R': '%H:%M', + '%r': '%I:%M:%S %p', + '%s': '', #num of seconds since epoch + '%T': '%H:%M:%S', + '%t': ' ', # tab + '%u': ' %w', + '%V': '%W', + '%y': '%Y', # Even if %y works, it's ambiguous, so we should use %Y + '%+': '%Y-%m-%d %H:%M:%S', + + # %Z is a special case that causes 2 problems at least: + # - the timezone names we use (in res_user.context_tz) come + # from pytz, but not all these names are recognized by + # strptime(), so we cannot convert in both directions + # when such a timezone is selected and %Z is in the format + # - %Z is replaced by an empty string in strftime() when + # there is not tzinfo in a datetime value (e.g when the user + # did not pick a context_tz). The resulting string does not + # parse back if the format requires %Z. + # As a consequence, we strip it completely from format strings. + # The user can always have a look at the context_tz in + # preferences to check the timezone. + '%z': '', + '%Z': '', +} + def server_to_local_timestamp(src_tstamp_str, src_format, dst_format, dst_tz_name, tz_offset=True, ignore_unparsable_time=True): """ diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 9724f732a6d..cfc747bafe0 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -376,7 +376,7 @@ class TinyPoFile(object): 'version': release.version, 'modules': reduce(lambda s, m: s + "#\t* %s\n" % m, modules, ""), 'bugmail': release.support_email, - 'now': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')+"+0000", + 'now': datetime.utcnow().strftime('%Y-%m-%d %H:%M')+"+0000", } ) @@ -919,7 +919,12 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, ('src', '=', dic['src']), ] if dic['type'] == 'model': - args.append(('res_id', '=', dic['res_id'])) + if dic['res_id'] is False: + args.append(('res_id', '=', 0)) + args.append(('module', '=', dic['module'])) + args.append(('xml_id', '=', dic['xml_id'])) + else: + args.append(('res_id', '=', dic['res_id'])) ids = trans_obj.search(cr, uid, args) if ids: if context.get('overwrite') and dic['value']: @@ -935,10 +940,10 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, def trans_update_res_ids(cr): cr.execute(""" UPDATE ir_translation - SET res_id = (SELECT ir_model_data.res_id + SET res_id = COALESCE ((SELECT ir_model_data.res_id FROM ir_model_data WHERE ir_translation.module = ir_model_data.module - AND ir_translation.xml_id = ir_model_data.name) + AND ir_translation.xml_id = ir_model_data.name), 0) WHERE ir_translation.module is not null AND ir_translation.xml_id is not null AND ir_translation.res_id = 0; |
