Merge lp:~savoirfairelinux-openerp/ocb-server/7.0_mail_thread_translate_bug1262000 into lp:ocb-server

Status: Merged
Merged at revision: 5281
Proposed branch: lp:~savoirfairelinux-openerp/ocb-server/7.0_mail_thread_translate_bug1262000
Merge into: lp:ocb-server
Diff against target: 15 lines (+5/-0)
1 file modified
openerp/tools/translate.py (+5/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/ocb-server/7.0_mail_thread_translate_bug1262000
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+208488@code.launchpad.net

Description of the change

Related to https://code.launchpad.net/~savoirfairelinux-openerp/ocb-addons/7.0_mail_thread_translate_bug1262000/+merge/207992

Makes it so model descriptions are translated and chatter_widget can display the model in the proper language.

To post a comment you must log in.
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

example output:

#. module: email_template
#: code:_description:0
#: model:ir.model,name:email_template.model_email_template
#, python-format
msgid "Email Templates"
msgstr ""

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! Something like this would really help in returning properly translated errors to the user, using _(model._description) in general. However, turning module names in a model name seems a bit simplistic.

Maybe try something like this instead:

=== modified file 'openerp/tools/translate.py'
--- openerp/tools/translate.py 2014-02-06 10:51:41 +0000
+++ openerp/tools/translate.py 2014-02-27 11:46:26 +0000
@@ -670,6 +670,11 @@
             _logger.warning("Unable to find object %r with id %d", model, res_id)
             continue
         obj = pool.get(model).browse(cr, uid, res_id)
+
+ if model == 'ir.model':
+ model_pool = pool.get(obj.model)
+ if model_pool:
+ push_translation(module, 'code', '_description', 0, model_pool._description)

         if model=='ir.ui.view':
             d = etree.XML(encode(obj.arch))

This will give duplicates for every module in which a model is inherited, but this is already the case for the equivalent "model:ir.model,name" entries.

review: Needs Fixing
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Launchpad oh launchpad, why drop meaningful whitespace...

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for taking my suggestion! I see you changed the translation type from 'code' to 'model'. For our purposes, I believe this is incorrect and does not lead to translations being fetched by _(model._description). Are you sure this works?

review: Needs Information
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

You are right, that was an oops on my part

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks!

review: Approve
5275. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)
5276. By Olivier Dony (Odoo)

[FIX] orm.read_group: fix various issues introduced in recent commit, cleanup

Fixed the implementation of the sorting for inherited
columns, many2one columns, and aggregated columns.
Added corresponding tests with increased coverage of
the read_group() method.

5277. By Olivier Dony (Odoo)

[FIX] orm.read_group: improve test coverage and corner case handling:

- allow leading spaces in orderby spec for m2o columns
- extra test for read_group on multiple columns
- proper handling of groupby on numeric column with default order

5278. By Martin Trigaux (OpenERP)

[MERGE] [FIX] orm: create a foreign key for the function fields of type many2one and store value (opw #604792)

5279. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

5280. By Martin Trigaux (OpenERP)

[MERGE] [FIX] test ir.sequence: when testing the lock mechanism, verify the error based on an error code instead of the error message which is sensible to the locale of the system

5281. By Sandy Carter (http://www.savoirfairelinux.com)

Add description to output of translation export so mail_tread creation messages can be translated

5282. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/tools/translate.py'
2--- openerp/tools/translate.py 2014-02-06 10:51:41 +0000
3+++ openerp/tools/translate.py 2014-02-27 23:46:31 +0000
4@@ -778,6 +778,11 @@
5 except (IOError, etree.XMLSyntaxError):
6 _logger.exception("couldn't export translation for report %s %s %s", name, report_type, fname)
7
8+ elif model == 'ir.model':
9+ model_pool = pool.get(obj.model)
10+ if model_pool:
11+ push_translation(module, 'code', '_description', 0, model_pool._description)
12+
13 for field_name,field_def in obj._table._columns.items():
14 if field_def.translate:
15 name = model + "," + field_name