[IMP] base: improve user password wizard

This commit fix the users login disappearance when
hitting 'Change Password' button without setting a
password by adding force_save parameter. It also
removes the required parameter from the new_passwd
field so we don't get a vague missing field error
when one omits to enter a new password. Instead of
an error, we just leave the old password for the
missing lines.

Task-3184727

Part-of: odoo/odoo#112806
This commit is contained in:
Patrick Hoste
2023-05-04 19:09:55 +02:00
parent 3c5d9e8e1d
commit cde4a9c647
2 changed files with 4 additions and 5 deletions
+2 -3
View File
@@ -1876,9 +1876,8 @@ class ChangePasswordUser(models.TransientModel):
def change_password_button(self):
for line in self:
if not line.new_passwd:
raise UserError(_("Before clicking on 'Change Password', you have to write a new password."))
line.user_id._change_password(line.new_passwd)
if line.new_passwd:
line.user_id._change_password(line.new_passwd)
# don't keep temporary passwords in the database longer than necessary
self.write({'new_passwd': False})
+2 -2
View File
@@ -39,8 +39,8 @@
<!-- the user list is editable, but one cannot add or delete rows -->
<tree string="Users" editable="bottom" create="false" delete="false">
<field name="user_id" invisible="1"/>
<field name="user_login"/>
<field name="new_passwd" required="True" password="True"/>
<field name="user_login" force_save="1"/>
<field name="new_passwd" password="True"/>
</tree>
</field>
</record>