Merge lp:~openerp-dev/openerp-web/7.0-ticket-604115-jam into lp:openerp-web/7.0

Proposed by Jigar A.
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/7.0-ticket-604115-jam
Merge into: lp:openerp-web/7.0
Diff against target: 30 lines (+3/-3)
1 file modified
addons/web/static/src/js/view_list.js (+3/-3)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-ticket-604115-jam
Reviewer Review Type Date Requested Status
Sandy Carter (http://www.savoirfairelinux.com) (community) code review, test Needs Fixing
OpenERP Core Team Pending
Review via email: mp+206540@code.launchpad.net

Description of the change

Many2many fields in Tree views will not get translated. If you check the context for a name_get of a m2m field, it is passed as None. Same i sthe case for many2one and reference fields.
Courtesy : Sandy Carter (http://www.savoirfairelinux.com), MSH
Thanks

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

Getting this error while using this patch at revno 4144.
Does not appear at revno 4143

Client Traceback (most recent call last):
  File "web/addons/web/http.py", line 197, in dispatch
    self.jsonrequest = simplejson.load(requestf, object_hook=reject_nonliteral)
  File "/usr/lib/python2.7/site-packages/simplejson/__init__.py", line 431, in load
    use_decimal=use_decimal, **kw)
  File "/usr/lib/python2.7/site-packages/simplejson/__init__.py", line 505, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
  File "web/addons/web/http.py", line 125, in reject_nonliteral
    "Non literal contexts can not be sent to the server anymore (%r)" % (dct,))
ValueError: Non literal contexts can not be sent to the server anymore ({'__ref': 'compound_context', '__contexts': [{'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 1}, {'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 1}, {}], '__eval_context': None})

review: Needs Fixing (code review, test)

Unmerged revisions

4144. By Jigar A.

[FIX] Added Missing Context for M2O and Reference Fields, To enable i18n. courtesy : MSH

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

[FIX] Added MIssing Context for M2M, To enable i18n.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/view_list.js'
--- addons/web/static/src/js/view_list.js 2014-01-15 11:00:38 +0000
+++ addons/web/static/src/js/view_list.js 2014-02-14 17:47:15 +0000
@@ -1020,7 +1020,7 @@
1020 // to get a correctly displayable value in the field1020 // to get a correctly displayable value in the field
1021 var model = ref_match[1],1021 var model = ref_match[1],
1022 id = parseInt(ref_match[2], 10);1022 id = parseInt(ref_match[2], 10);
1023 new instance.web.DataSet(this.view, model).name_get([id]).done(function(names) {1023 new instance.web.DataSet(this.view, model).name_get([id, this.dataset.context]).done(function(names) {
1024 if (!names.length) { return; }1024 if (!names.length) { return; }
1025 record.set(column.id + '__display', names[0][1]);1025 record.set(column.id + '__display', names[0][1]);
1026 });1026 });
@@ -1036,7 +1036,7 @@
1036 // and let the various registered events handle refreshing the1036 // and let the various registered events handle refreshing the
1037 // row1037 // row
1038 new instance.web.DataSet(this.view, column.relation)1038 new instance.web.DataSet(this.view, column.relation)
1039 .name_get([value]).done(function (names) {1039 .name_get([value, this.dataset.context]).done(function (names) {
1040 if (!names.length) { return; }1040 if (!names.length) { return; }
1041 record.set(column.id, names[0]);1041 record.set(column.id, names[0]);
1042 });1042 });
@@ -1060,7 +1060,7 @@
1060 ids = value;1060 ids = value;
1061 }1061 }
1062 new instance.web.Model(column.relation)1062 new instance.web.Model(column.relation)
1063 .call('name_get', [ids]).done(function (names) {1063 .call('name_get', [ids, this.dataset.context]).done(function (names) {
1064 // FIXME: nth horrible hack in this poor listview1064 // FIXME: nth horrible hack in this poor listview
1065 record.set(column.id + '__display',1065 record.set(column.id + '__display',
1066 _(names).pluck(1).join(', '));1066 _(names).pluck(1).join(', '));