[FIX] base_import: handle exception while import image in url form

An error will be generated when a user tries to import or upload a file into the
 invoice module and the file is attached to an image via a URL form but the
 image is invalid or cannot be found.

step to reproduce-
- install the `Accounting`.
- open Accounting > Vendors Menu > Products.
- import file (image url must be invalid or not found )
- the error will be generated.

At the time of solving the conflicts of FW mistakenly changed the
"ImportValidationError" to "ValueError". Due to these changes,
the error is shown in the log.

FW - https://github.com/odoo/odoo/pull/137596
sentry-4538772256

closes odoo/odoo#144011

X-original-commit: 581c0c69f368f08bcf9803942027b172b8bc2694
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
Sanket Brahmbhatt
2023-11-30 10:13:26 +00:00
parent d0f9d8cca7
commit ed98a580f4
+1 -1
View File
@@ -1271,7 +1271,7 @@ class Import(models.TransientModel):
return base64.b64encode(content)
except Exception as e:
_logger.warning(e, exc_info=True)
raise ValueError(_("Could not retrieve URL: %(url)s [%(field_name)s: L%(line_number)d]: %(error)s") % {
raise ImportValidationError(_("Could not retrieve URL: %(url)s [%(field_name)s: L%(line_number)d]: %(error)s") % {
'url': url,
'field_name': field,
'line_number': line_number + 1,