[FIX] base,tools: raise usererror instead of a valueerror
This issue is generated when the user uploads an image of more than 50.0 million pixels, so error would be generated. But, currently it raises a `ValueError` which results in traceback. So, we replace it with `UserError` so the user has an idea about Image size or pixel being excessive. closes odoo/odoo#121396 Sentry: - 4075426049 X-original-commit: ac2a3966cb035f112bf6aebb1244dc8d67831d1a Signed-off-by: Rémy Voet <ryv@odoo.com>
This commit is contained in:
@@ -157,7 +157,7 @@ class TestImage(TransactionCase):
|
||||
res = tools.image_process(self.img_1920x1080_jpeg, verify_resolution=True)
|
||||
self.assertNotEqual(res, False, "size ok")
|
||||
image_excessive = tools.image_apply_opt(Image.new('RGB', (50001, 1000)), 'PNG')
|
||||
with self.assertRaises(ValueError, msg="size excessive"):
|
||||
with self.assertRaises(UserError, msg="size excessive"):
|
||||
tools.image_process(image_excessive, verify_resolution=True)
|
||||
|
||||
def test_13_image_process_quality(self):
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ class ImageProcess():
|
||||
|
||||
w, h = self.image.size
|
||||
if verify_resolution and w * h > IMAGE_MAX_RESOLUTION:
|
||||
raise ValueError(_("Image size excessive, uploaded images must be smaller than %s million pixels.", str(IMAGE_MAX_RESOLUTION / 1e6)))
|
||||
raise UserError(_("Image size excessive, uploaded images must be smaller than %s million pixels.", str(IMAGE_MAX_RESOLUTION / 1e6)))
|
||||
|
||||
def image_quality(self, quality=0, output_format=''):
|
||||
"""Return the image resulting of all the image processing
|
||||
|
||||
Reference in New Issue
Block a user