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

Subscribers

People subscribed via source and target branches