Merge lp:~openerp-dev/openobject-server/trunk-website_html_field_translation-pga into lp:openobject-server

Proposed by Thibault Delavallée (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/trunk-website_html_field_translation-pga
Merge into: lp:openobject-server
Diff against target: 34 lines (+15/-2)
1 file modified
openerp/addons/base/ir/ir_qweb.py (+15/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-website_html_field_translation-pga
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+216703@code.launchpad.net

Description of the change

TO UDPATE

To post a comment you must log in.

Unmerged revisions

5185. By Parth Gajjar(Open ERP)

merged with trunk

5184. By Parth Gajjar(Open ERP)

merged with trunk

5183. By Parth Gajjar(Open ERP)

[IMP] translated from translation term if field type is html

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_qweb.py'
2--- openerp/addons/base/ir/ir_qweb.py 2014-04-16 08:54:07 +0000
3+++ openerp/addons/base/ir/ir_qweb.py 2014-04-22 12:17:41 +0000
4@@ -479,6 +479,13 @@
5 ('data-oe-expression', t_att['field']),
6 ]
7
8+ def translate_html(self, cr, uid, trans_name, res_id, value, context=None):
9+ if context.get('lang'):
10+ for trans in self.pool['ir.translation'].search_read(cr, uid, [('name', '=', trans_name),('res_id', '=', res_id),('lang', '=', context.get('lang'))],['source','value']):
11+ if trans['value']:
12+ value = value.replace(trans['source'], trans['value'])
13+ return value
14+
15 def value_to_html(self, cr, uid, value, column, options=None, context=None):
16 """ Converts a single value to its HTML version/output
17 """
18@@ -489,8 +496,14 @@
19 """ Converts the specified field of the browse_record ``record`` to
20 HTML
21 """
22- return self.value_to_html(
23- cr, uid, record[field_name], column, options=options, context=context)
24+ if column._type == 'html':
25+ trans_name = ('%s,%s')%(record._table_name,field_name)
26+ value = self.translate_html(cr, uid, trans_name, record.id, record[field_name],context)
27+ return self.value_to_html(
28+ cr, uid, value, column, options=options, context=context)
29+ else:
30+ return self.value_to_html(
31+ cr, uid, record[field_name], column, options=options, context=context)
32
33 def to_html(self, cr, uid, field_name, record, options,
34 source_element, t_att, g_att, qweb_context, context=None):