[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#63999

X-original-commit: 0918b29ce765a159ba2b128bca9170f1230fdb78
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2021-01-04 11:34:13 +00:00
parent d534a216ba
commit 85750746f6
2 changed files with 11 additions and 2 deletions
+6
View File
@@ -18694,6 +18694,12 @@ msgid ""
"again after refreshing."
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
+5 -2
View File
@@ -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)