From aaeb708089a7c5403c5bfa6e758d1fb3266efdff Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 12 Jun 2020 08:57:28 +0000 Subject: [PATCH] [FIX] website: create ir.ui.view, don't crypt Falsy password MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When you create an ir_ui_view form the backend, the encrypt function was called with a Falsy value and crash with error: TypeError: secret must be unicode or bytes, not bool Now, when you create view from backend, we only set password if it is a qweb view. In case of update, the field is dirty, so if you don't update it, it will be not write. closes odoo/odoo#53348 X-original-commit: 3d9101db0f7cc0adc1f34721c38b4c2f7089566d Signed-off-by: Jérémy Kersten (jke) --- addons/website/models/ir_ui_view.py | 5 +++-- addons/website/views/website_views.xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index a24e8f584f6..d65f3ca11b5 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -39,8 +39,9 @@ class View(models.Model): def _set_pwd(self): crypt_context = self.env.user._crypt_context() for r in self: - r.sudo().visibility_password = crypt_context.encrypt(r.visibility_password_display) - r.visibility = r.visibility # double check access + if r.type == 'qweb': + r.sudo().visibility_password = r.visibility_password_display and crypt_context.encrypt(r.visibility_password_display) or '' + r.visibility = r.visibility # double check access def _compute_first_page_id(self): for view in self: diff --git a/addons/website/views/website_views.xml b/addons/website/views/website_views.xml index a9996029567..970aa309523 100644 --- a/addons/website/views/website_views.xml +++ b/addons/website/views/website_views.xml @@ -272,7 +272,7 @@ - +