diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2017-08-24 13:22:13 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2017-08-28 14:22:47 +0200 |
| commit | f32a79dd82b592c9419829db9e9cbaf4d268a967 (patch) | |
| tree | bb6daf4ce626c9e1bf41b40a8908a48be59b91b9 /addons/web/controllers | |
| parent | 15cb84e0f77db350560aac9d32d947e919def128 (diff) | |
[FIX] web: limit amount of rows for excel export
Before this commit, when the amount of rows was above xls format threshold (>65535), the xlwt library threw an obscure Traceback to the user.
We now test the amount of rows before even calling the library, raising a more helpful message to the user
OPW 767319
closes #19035
Diffstat (limited to 'addons/web/controllers')
| -rw-r--r-- | addons/web/controllers/main.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 3dc9d4526bc..636f37d293e 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -35,7 +35,7 @@ from openerp.tools import ustr from openerp.tools.misc import str2bool, xlwt from openerp import http from openerp.http import request, serialize_exception as _serialize_exception, content_disposition -from openerp.exceptions import AccessError +from openerp.exceptions import AccessError, UserError _logger = logging.getLogger(__name__) @@ -1419,6 +1419,9 @@ class ExcelExport(ExportFormat, http.Controller): return base + '.xls' def from_data(self, fields, rows): + if len(rows) > 65535: + raise UserError(_('There are too many rows (%s rows, limit: 65535) to export as Excel 97-2003 (.xls) format. Consider splitting the export.') % len(rows)) + workbook = xlwt.Workbook() worksheet = workbook.add_sheet('Sheet 1') |
