Merge lp:~eoc/web-addons/6.1-web-addons_fix_number_parsing_add_es_translation into lp:~webaddons-core-editors/web-addons/6.1

Proposed by Mariano Ruiz
Status: Rejected
Rejected by: Guewen Baconnier @ Camptocamp
Proposed branch: lp:~eoc/web-addons/6.1-web-addons_fix_number_parsing_add_es_translation
Merge into: lp:~webaddons-core-editors/web-addons/6.1
Diff against target: 116 lines (+65/-2)
4 files modified
web_export_view/AUTHORS.txt (+1/-0)
web_export_view/__openerp__.py (+1/-1)
web_export_view/controllers.py (+43/-1)
web_export_view/i18n/es.po (+20/-0)
To merge this branch: bzr merge lp:~eoc/web-addons/6.1-web-addons_fix_number_parsing_add_es_translation
Reviewer Review Type Date Requested Status
Cristian Salamea (community) Needs Information
Holger Brunn (Therp) Needs Fixing
Web-Addons Core Editors Pending
Review via email: mp+167570@code.launchpad.net

This proposal supersedes a proposal from 2013-06-05.

Description of the change

We fix the issue #1046342 in this branch.

Also we add Spanish translation .po file.

... I'm fix the request proposal changing the target to the 6.1 version.

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

#44 you should check if xlwt is not None and issue a warning otherwise
#53ff I think you're better off using locale.setlocale(locale.LC_NUMERIC, context.get('lang', 'en_US')) and locale.atof afterwards. setlocale raises if the locale is not installed, so better catch that too
#68 the comment contradicts what you do. I think you want to suppress the ValueError (and better also only except that)

review: Needs Fixing
Revision history for this message
Cristian Salamea (ovnicraft) wrote :

Hi Mariano, i did some work around this and made a MP https://code.launchpad.net/~ovnicraft/web-addons/6.1-export-view-float-field/+merge/169678

So i'd like check my code to cooperate and make one merge.

Just comments about my code.

Decimal separators read from res.lang object.
Regexp to identify thousands and decimals.
Apply number format in XLS cell.

Waiting for your comments !

Regards,

review: Needs Information
Revision history for this message
Mariano Ruiz (marianoruiz) wrote :

Yea Cristian, I put a comment about the proposal of that branch, I think than with some fix, will be a better solution than my branch.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> Yea Cristian, I put a comment about the proposal of that branch, I think than
> with some fix, will be a better solution than my branch.

So can we close this MP, or put it in 'Work in progress' meanwhile a solution is found?

Revision history for this message
Cristian Salamea (ovnicraft) wrote :

We with Mariano are commenting in my MP, we can close this.

Regards,

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

> We with Mariano are commenting in my MP, we can close this.
>
> Regards,

I put it as 'rejected' to reflect that.

Unmerged revisions

13. By Mariano Ruiz

[FIX] Convert number string to float number. Parse according with the context lang [IMP] Add Spanish translation

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'web_export_view/AUTHORS.txt'
2--- web_export_view/AUTHORS.txt 2013-01-28 18:35:43 +0000
3+++ web_export_view/AUTHORS.txt 2013-06-05 15:35:36 +0000
4@@ -4,3 +4,4 @@
5 Simone Orsi <simone.orsi@domsense.com> [simahawk]
6 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7 Stefan Rijnhart <stefan@therp.nl>
8+Mariano Ruiz <mrsarm@gmail.com>
9
10=== modified file 'web_export_view/__openerp__.py'
11--- web_export_view/__openerp__.py 2013-01-20 15:16:52 +0000
12+++ web_export_view/__openerp__.py 2013-06-05 15:35:36 +0000
13@@ -22,7 +22,7 @@
14
15 {
16 'name': 'Export Current View',
17- 'version': '1.0',
18+ 'version': '1.0.1',
19 'category': 'Web',
20 'description': """
21 WEB EXPORT VIEW
22
23=== modified file 'web_export_view/controllers.py'
24--- web_export_view/controllers.py 2013-01-20 15:16:52 +0000
25+++ web_export_view/controllers.py 2013-06-05 15:35:36 +0000
26@@ -22,6 +22,12 @@
27 import json
28 except ImportError:
29 import simplejson as json
30+import re
31+from cStringIO import StringIO
32+try:
33+ import xlwt
34+except ImportError:
35+ xlwt = None
36
37 import web.common.http as openerpweb
38
39@@ -31,6 +37,42 @@
40 class ExcelExportView(ExcelExport):
41 _cp_path = '/web/export/xls_view'
42
43+ def from_data(self, fields, rows, context):
44+ workbook = xlwt.Workbook()
45+ worksheet = workbook.add_sheet('Sheet 1')
46+
47+ for i, fieldname in enumerate(fields):
48+ worksheet.write(0, i, fieldname)
49+ worksheet.col(i).width = 8000 # around 220 pixels
50+
51+ style = xlwt.easyxf('align: wrap yes')
52+
53+ en_lang = context.get('lang', '').startswith('en')
54+ latin_lang = not en_lang and context.get('lang', '').startswith('es')
55+ for row_index, row in enumerate(rows):
56+ for cell_index, cell_value in enumerate(row):
57+ if isinstance(cell_value, basestring):
58+ cell_value = re.sub("\r", " ", cell_value)
59+ if cell_value is False: cell_value = None
60+ try:
61+ if en_lang:
62+ # Number format with "." decimal separator, ex. "4567.40"
63+ cell_value = float(cell_value)
64+ elif latin_lang:
65+ # Number format with "," decimal separator, ex. "4567,40"
66+ cell_value = float(cell_value.replace(",", "."))
67+ except:
68+ # If the cell is not a number raise a ValueError
69+ pass
70+ worksheet.write(row_index + 1, cell_index, cell_value, style)
71+
72+ fp = StringIO()
73+ workbook.save(fp)
74+ fp.seek(0)
75+ data = fp.read()
76+ fp.close()
77+ return data
78+
79 @openerpweb.httprequest
80 def index(self, req, data, token):
81 data = json.loads(data)
82@@ -40,7 +82,7 @@
83
84 context = req.session.eval_context(req.context)
85
86- return req.make_response(self.from_data(columns_headers, rows),
87+ return req.make_response(self.from_data(columns_headers, rows, context),
88 headers=[('Content-Disposition', 'attachment; filename="%s"' % self.filename(model)),
89 ('Content-Type', self.content_type)],
90 cookies={'fileToken': int(token)})
91
92=== added directory 'web_export_view/i18n'
93=== added file 'web_export_view/i18n/es.po'
94--- web_export_view/i18n/es.po 1970-01-01 00:00:00 +0000
95+++ web_export_view/i18n/es.po 2013-06-05 15:35:36 +0000
96@@ -0,0 +1,20 @@
97+# Spanish translation for web_export_view
98+# This file is distributed under the same license as the web_export_view package.
99+# Mariano Ruiz <mrsarm@gmail.com>, 2013.
100+#
101+msgid ""
102+msgstr ""
103+"POT-Creation-Date: 2013-06-05 12:40+0200\n"
104+"PO-Revision-Date: 2013-06-05 11:25+0000\n"
105+"Last-Translator: Mariano Ruiz <mrsarm@gmail.com>\n"
106+"Language-Team: Enterprise Objects Consulting <info@eoconsulting.com.ar>\n"
107+"MIME-Version: 1.0\n"
108+"Content-Type: text/plain; charset=UTF-8\n"
109+"Content-Transfer-Encoding: 8bit\n"
110+
111+#. module: web_export_view
112+#. openerp-web
113+#: code:addons/web_export_view/static/js/web_advanced_export.js:56
114+#, python-format
115+msgid "Export current view"
116+msgstr "Exportar datos actuales"

Subscribers

People subscribed via source and target branches