Skip to content
Permalink
Browse files

[FIX] tools: empty name

Check if name isn't empty before executing regex. xlsxwriter can handle
an empty name.

opw-769163
Closes #18877
  • Loading branch information...
adrienpeiffer authored and nim-odoo committed Aug 16, 2017
1 parent 65f5fc6 commit 0fff391c381c58d60a9141464226741cc4df6ae6
Showing with 5 additions and 4 deletions.
  1. +5 −4 odoo/tools/misc.py
@@ -372,11 +372,12 @@ class PatchedXlsxWorkbook(xlsxwriter.Workbook):

# TODO when xlsxwriter bump to 0.9.8, add worksheet_class=None parameter instead of kw
def add_worksheet(self, name=None, **kw):
# invalid Excel character: []:*?/\
name = re.sub(r'[\[\]:*?/\\]', '', name)
if name:
# invalid Excel character: []:*?/\
name = re.sub(r'[\[\]:*?/\\]', '', name)

# maximum size is 31 characters
name = name[:31]
# maximum size is 31 characters
name = name[:31]
return super(PatchedXlsxWorkbook, self).add_worksheet(name, **kw)

xlsxwriter.Workbook = PatchedXlsxWorkbook

0 comments on commit 0fff391

Please sign in to comment.
You can’t perform that action at this time.