[FIX] website: create ir.ui.view, don't crypt Falsy password

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) <jke@openerp.com>
This commit is contained in:
Jeremy Kersten
2020-06-19 15:03:11 +00:00
parent adb908fb32
commit aaeb708089
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -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:
+1 -1
View File
@@ -272,7 +272,7 @@
<field name="page_ids" invisible="1" />
<field name="first_page_id" attrs="{'invisible': [('page_ids', '=', [])]}" />
<field name="visibility" attrs="{'invisible': [('type', '!=', 'qweb')]}" />
<field name="visibility_password_display" attrs="{'invisible': [('visibility', '!=', 'password')]}" password="True"/>
<field name="visibility_password_display" attrs="{'invisible': [('visibility', '!=', 'password')]}" password="True" string="Visibility Password" />
</field>
<sheet position="before">
<header>