Commit 91b7898
committed
[FIX] sale_pdf_quote_builder: prevent errors when handling non-PDF files
Currently an error occurs when user uploads a non-pdf file on product documents.
Steps to replicate:
- Install `sale_management` and go to products.
- Open any product's form view and click on the `Documents` smart button.
- Click new and upload any non-pdf file.
- On the field `Sale : Visible at`, select the value `inside quote pdf` and you
will get the error.
Error:
`PdfReadError: EOF marker not found`
The error occurs because at the line [1] the code requires a pdf file, and as we
have passed a non-pdf file the error occurs.
[1] - https://github.com/odoo/odoo/blob/e750244c3125a48e2ca030160b977bb0344609db/addons/sale_pdf_quote_builder/models/sale_pdf_form_field.py#L206
There is already a constraint made for this particular thing [2], but the
problem is that the error is due the compute [3] (Because constraints are
checked at the time of form saving, and compute runs when a field is changed so
even before the constraint is checked the error will be triggered).
[2] - https://github.com/odoo/odoo/blob/e750244c3125a48e2ca030160b977bb0344609db/addons/sale_pdf_quote_builder/models/product_document.py#L44-L45
[3] - https://github.com/odoo/odoo/blob/e750244c3125a48e2ca030160b977bb0344609db/addons/sale_pdf_quote_builder/models/product_document.py#L59-L61
This commit resolves this issue by skipping the pdf extraction if the file is
not a pdf type, because we already have a constraint [2] that will trigger
at save.
sentry-6161120972
closes odoo#220678
X-original-commit: ccf8f3c
Signed-off-by: Bhavya Ashesh Nanavati (bhna) <bhna@odoo.com>1 parent 6a54348 commit 91b7898
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
197 | 214 | | |
198 | 215 | | |
199 | 216 | | |
| |||
0 commit comments