mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-23 17:12:08 +02:00
19.0 vanilla
This commit is contained in:
parent
0a7ae8db93
commit
991d2234ca
416 changed files with 646602 additions and 300844 deletions
22
odoo-bringout-oca-ocb-base/odoo/_monkeypatches/xlsxwriter.py
Normal file
22
odoo-bringout-oca-ocb-base/odoo/_monkeypatches/xlsxwriter.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
Patch xlsxwriter to add some sanitization to respect the excel sheet name
|
||||
restrictions as the sheet name is often translatable, can not control the input
|
||||
"""
|
||||
import re
|
||||
|
||||
import xlsxwriter
|
||||
|
||||
|
||||
class PatchedXlsxWorkbook(xlsxwriter.Workbook):
|
||||
def add_worksheet(self, name=None, worksheet_class=None):
|
||||
if name:
|
||||
# invalid Excel character: []:*?/\
|
||||
name = re.sub(r'[\[\]:*?/\\]', '', name)
|
||||
|
||||
# maximum size is 31 characters
|
||||
name = name[:31]
|
||||
return super().add_worksheet(name, worksheet_class=worksheet_class)
|
||||
|
||||
|
||||
def patch_module():
|
||||
xlsxwriter.Workbook = PatchedXlsxWorkbook
|
||||
Loading…
Add table
Add a link
Reference in a new issue