Merge lp:~camptocamp/openobject-addons/6.0_bug_897412 into lp:openobject-addons/6.0

Proposed by Nicolas Bessi - Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/6.0_bug_897412
Merge into: lp:openobject-addons/6.0
Diff against target: 70 lines (+6/-40)
1 file modified
report_webkit/webkit_report.py (+6/-40)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/6.0_bug_897412
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+88707@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

5001. By Nicolas Bessi - Camptocamp on 2012-01-16

[FIX] bug 897412

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'report_webkit/webkit_report.py'
2--- report_webkit/webkit_report.py 2011-06-30 10:04:21 +0000
3+++ report_webkit/webkit_report.py 2012-01-16 15:04:08 +0000
4@@ -176,51 +176,19 @@
5
6 os.unlink(out)
7 return pdf
8-
9-
10- def setLang(self, lang):
11- if not lang:
12- lang = 'en_US'
13- self.localcontext['lang'] = lang
14
15 def translate_call(self, src):
16 """Translate String."""
17 ir_translation = self.pool.get('ir.translation')
18- res = ir_translation._get_source(self.parser_instance.cr, self.parser_instance.uid, self.name, 'report', self.localcontext.get('lang', 'en_US'), src)
19+ res = ir_translation._get_source(self.parser_instance.cr,
20+ self.parser_instance.uid,
21+ self.name, 'report',
22+ self.parser_instance.localcontext.get('lang', 'en_US'),
23+ src)
24 if not res :
25 return src
26 return res
27-
28- def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False):
29- """format using the know cursor, language from localcontext"""
30- if digits is None:
31- digits = self.parser_instance.get_digits(value)
32- if isinstance(value, (str, unicode)) and not value:
33- return ''
34- pool_lang = self.pool.get('res.lang')
35- lang = self.localcontext['lang']
36-
37- lang_ids = pool_lang.search(self.parser_instance.cr, self.parser_instance.uid, [('code','=',lang)])[0]
38- lang_obj = pool_lang.browse(self.parser_instance.cr, self.parser_instance.uid, lang_ids)
39-
40- if date or date_time:
41- if not str(value):
42- return ''
43-
44- date_format = lang_obj.date_format
45- parse_format = '%Y-%m-%d'
46- if date_time:
47- value=value.split('.')[0]
48- date_format = date_format + " " + lang_obj.time_format
49- parse_format = '%Y-%m-%d %H:%M:%S'
50- if not isinstance(value, time.struct_time):
51- return time.strftime(date_format, time.strptime(value, parse_format))
52-
53- else:
54- date = datetime(*value.timetuple()[:6])
55- return date.strftime(date_format)
56-
57- return lang_obj.format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary)
58+
59
60 # override needed to keep the attachments' storing procedure
61 def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
62@@ -294,8 +262,6 @@
63 #default_filters=['unicode', 'entity'] can be used to set global filter
64 body_mako_tpl = mako_template(template)
65 helper = WebKitHelper(cursor, uid, report_xml.id, context)
66- self.parser_instance.localcontext.update({'setLang':self.setLang})
67- self.parser_instance.localcontext.update({'formatLang':self.formatLang})
68 try :
69 html = body_mako_tpl.render( helper=helper,
70 css=css,