From 58114e49545c4e3e8ebadec46fb4463d13e9ccbf Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 5 May 2017 16:55:12 +0200 Subject: [PATCH 1/5] [FIX] tools: always preload PIL with basic formats Ensures that only the desired list of images formats are made available via PIL: BMP, GIF, PNG, JPEG, TIFF and PPM. --- openerp/tools/image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/tools/image.py b/openerp/tools/image.py index f1293b52fff..251569c7247 100644 --- a/openerp/tools/image.py +++ b/openerp/tools/image.py @@ -28,6 +28,10 @@ from PIL import Image from PIL import ImageEnhance from random import randint +# Preload PIL with the minimal subset of image formats we need +Image.preinit() +Image._initialized = 2 + # ---------------------------------------- # Image resizing # ---------------------------------------- From ca27673a54612eec6197a233c5f7830e112431c1 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 5 May 2017 16:55:12 +0200 Subject: [PATCH 2/5] [FIX] tools: always preload PIL with basic formats Ensures that only the desired list of images formats are made available via PIL: BMP, GIF, PNG, JPEG, TIFF and PPM. --- openerp/tools/image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/tools/image.py b/openerp/tools/image.py index 7a6742ce04d..a0cd44a8014 100644 --- a/openerp/tools/image.py +++ b/openerp/tools/image.py @@ -28,6 +28,10 @@ from PIL import Image from PIL import ImageEnhance from random import randint +# Preload PIL with the minimal subset of image formats we need +Image.preinit() +Image._initialized = 2 + # ---------------------------------------- # Image resizing # ---------------------------------------- From 180c769ab4c4093f1e681e0f44ae0a7cf452bccd Mon Sep 17 00:00:00 2001 From: Kevin Graveman Date: Mon, 8 May 2017 13:42:08 +0200 Subject: [PATCH 3/5] [FIX] hr_timesheet_invoice: Typo in html element name tbody Closes #16827 --- addons/hr_timesheet_invoice/views/report_analyticprofit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_invoice/views/report_analyticprofit.xml b/addons/hr_timesheet_invoice/views/report_analyticprofit.xml index c067a9b1d2d..535a9a5a9f9 100644 --- a/addons/hr_timesheet_invoice/views/report_analyticprofit.xml +++ b/addons/hr_timesheet_invoice/views/report_analyticprofit.xml @@ -34,7 +34,7 @@ Eff. - + Totals: @@ -74,7 +74,7 @@ - + From 397871399673aab6e6d2d93e1873527b4022f2b0 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 10 May 2017 19:05:48 +0200 Subject: [PATCH 4/5] [FIX] mass-mailing: unsubscribe even when archived A record (Partner/Lead) that was archived can still be unsubscribed. --- addons/mass_mailing/controllers/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index 325ac1447d6..3e97435940e 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -37,7 +37,8 @@ class MassMailController(http.Controller): elif 'email' in model._fields: email_fname = 'email' if email_fname: - record_ids = model.search(cr, SUPERUSER_ID, [('id', '=', res_id), (email_fname, 'ilike', email)], context=context) + ctx = dict(context or {}, active_test=False) + record_ids = model.search(cr, SUPERUSER_ID, [('id', '=', res_id), (email_fname, 'ilike', email)], context=ctx) if 'opt_out' in model._fields: model.write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context) return 'OK' From e0014387c5ed45935b29b36be821e42460fa83fa Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 10 May 2017 18:58:01 +0200 Subject: [PATCH 5/5] [FIX] report: always close pdf files after merge If an exception during the merges (such as a file descriptor overrun), we would otherwise depend on the next garbage collection to close the files. But the next GC may never come. For example if we ran out of OS file descriptors during merge, all future requests will crash for the same reason, and the process will never recover because the GC will never run. Much easier to explicitly close the files all the time. --- addons/report/models/report.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/addons/report/models/report.py b/addons/report/models/report.py index 3c7d19fcc3a..36200ce9839 100644 --- a/addons/report/models/report.py +++ b/addons/report/models/report.py @@ -560,19 +560,23 @@ class Report(osv.Model): """ writer = PdfFileWriter() streams = [] # We have to close the streams *after* PdfFilWriter's call to write() - for document in documents: - pdfreport = file(document, 'rb') - streams.append(pdfreport) - reader = PdfFileReader(pdfreport) - for page in range(0, reader.getNumPages()): - writer.addPage(reader.getPage(page)) + try: + for document in documents: + pdfreport = file(document, 'rb') + streams.append(pdfreport) + reader = PdfFileReader(pdfreport) + for page in range(0, reader.getNumPages()): + writer.addPage(reader.getPage(page)) - merged_file_fd, merged_file_path = tempfile.mkstemp(suffix='.html', prefix='report.merged.tmp.') - with closing(os.fdopen(merged_file_fd, 'w')) as merged_file: - writer.write(merged_file) - - for stream in streams: - stream.close() + merged_file_fd, merged_file_path = tempfile.mkstemp(suffix='.pdf', prefix='report.merged.tmp.') + with closing(os.fdopen(merged_file_fd, 'w')) as merged_file: + writer.write(merged_file) + finally: + for stream in streams: + try: + stream.close() + except Exception: + pass return merged_file_path