[FIX] website: redirect only when url_to given

While creating redirects/rewrite if the user does not enter any url in the
'Url to' field of the website module under 'Configuartion/Redirects' then during
redirection, the error  'NotFound: 404 Not Found: The requested URL was not
found on  the server' will be produced.

Applying this commit will solve the issue.

sentry-4206504892

closes odoo/odoo#123391

X-original-commit: 14a850976711431f36b7f889ea9cf31b1114513d
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Saurabh Mishra (sami) <sami@odoo.com>
This commit is contained in:
Saurabh Mishra
2023-06-02 07:56:59 +02:00
parent 395d74aa11
commit 0184788ebd
+1 -1
View File
@@ -82,7 +82,7 @@ class WebsiteRewrite(models.Model):
@api.constrains('url_to', 'url_from', 'redirect_type')
def _check_url_to(self):
for rewrite in self:
if rewrite.redirect_type == '308':
if rewrite.redirect_type in ['301', '302', '308']:
if not rewrite.url_to:
raise ValidationError(_('"URL to" can not be empty.'))
elif not rewrite.url_to.startswith('/'):