diff options
| author | Goffin Simon <sig@odoo.com> | 2020-12-30 15:43:02 +0000 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2021-01-04 10:30:44 +0000 |
| commit | 679b5893f04ac4c8a8093f9538e9f4653224bd69 (patch) | |
| tree | 0e6acb12081528be5104ab0b8cca331d4284b140 | |
| parent | d8f7d7369f060f444bcebc0118cc5a2a650f6361 (diff) | |
[FIX] base: Original bills on encrypted pdf
Steps to reproduce the bug:
-Let's consider two vendor bills VB1 and VB2
-VB1 and VB2 have both a PDF in attachment P1 and P2 respectively (the original bills from the suppliers)
-Let's consider that P2 is encrypted
- In the list view of vendor bills, select VB1 and VB2 and print original bills
Bug:
An error was raised because it is not possible to merge P2 with P1 as P2 is encrypted.
opw:2389679
closes odoo/odoo#63990
X-original-commit: 0918b29ce765a159ba2b128bca9170f1230fdb78
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
| -rw-r--r-- | odoo/addons/base/i18n/base.pot | 6 | ||||
| -rw-r--r-- | odoo/addons/base/models/ir_actions_report.py | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/odoo/addons/base/i18n/base.pot b/odoo/addons/base/i18n/base.pot index 969a8b99ad2..7575d7cba03 100644 --- a/odoo/addons/base/i18n/base.pot +++ b/odoo/addons/base/i18n/base.pot @@ -18889,6 +18889,12 @@ msgid "" msgstr "" #. module: base +#: code:addons/base/models/ir_actions_report.py:0 +#, python-format +msgid "One of the documents, you try to merge is encrypted" +msgstr "" + +#. module: base #: code:addons/models.py:0 #, python-format msgid "" diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index 33762e46fb4..debd5a6997e 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -23,7 +23,7 @@ from lxml import etree from contextlib import closing from distutils.version import LooseVersion from reportlab.graphics.barcode import createBarcodeDrawing -from PyPDF2 import PdfFileWriter, PdfFileReader +from PyPDF2 import PdfFileWriter, PdfFileReader, utils from collections import OrderedDict from collections.abc import Iterable from PIL import Image, ImageFile @@ -678,7 +678,10 @@ class IrActionsReport(models.Model): if len(streams) == 1: result = streams[0].getvalue() else: - result = self._merge_pdfs(streams) + try: + result = self._merge_pdfs(streams) + except utils.PdfReadError: + raise UserError(_("One of the documents, you try to merge is encrypted")) # We have to close the streams after PdfFileWriter's call to write() close_streams(streams) |
