summaryrefslogtreecommitdiff
path: root/odoo/tools
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-09-06 17:40:59 +0200
committerChristophe Simonis <chs@odoo.com>2017-09-06 17:40:59 +0200
commitd5382abeaad4d93b8def7e63cd47a86baaba8f0b (patch)
tree6364ff760709b541eebdde4b04494b480dec87fb /odoo/tools
parentc75fe95dfca366bf6c3b6a51908677039488aa4f (diff)
parentb8dd34fcbb895b8d62f3e133dcf5ee6f40a1400d (diff)
[MERGE] forward port branch saas-17 up to b8dd34fcbb8
Diffstat (limited to 'odoo/tools')
-rw-r--r--odoo/tools/misc.py9
-rw-r--r--odoo/tools/sql.py10
2 files changed, 12 insertions, 7 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index 9116e08cec8..9eabfd13bd9 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -371,11 +371,12 @@ try:
# 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
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index 75f71b2e6b4..ff52c5b580a 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -23,14 +23,18 @@ _CONFDELTYPES = {
def existing_tables(cr, tablenames):
""" Return the names of existing tables among ``tablenames``. """
- query = """ SELECT table_name FROM information_schema.tables
- WHERE table_name IN %s AND table_schema != 'information_schema' """
+ query = """
+ SELECT relname
+ FROM pg_class
+ WHERE relname IN %s
+ AND relkind IN ('r', 'v', 'm')
+ """
cr.execute(query, [tuple(tablenames)])
return [row[0] for row in cr.fetchall()]
def table_exists(cr, tablename):
""" Return whether the given table exists. """
- query = "SELECT 1 FROM information_schema.tables WHERE table_name=%s AND table_schema != 'information_schema'"
+ query = "SELECT 1 FROM pg_class WHERE relkind IN ('r', 'v', 'm') AND relname=%s"
cr.execute(query, (tablename,))
return cr.rowcount