I want when user change new password, have to enter current password.
So I created 'confirm_password' field to check the password which the users enter correct with the password in login.
this is my code. But it not working.
Please help me...
def check_password(self, id, password):
user= (
request.env["res.users"]
.sudo()
.search([("id", "=", id), ("password", "=", password)], limit=1)
)
if user:
return user
else:
raiseSomethingWentWrong()
def change_new_password(self, id, password, new_password):
user=self.check_password(id, password)
if user:
result=user.sudo().write({"password": new_password})
if result:
return result
else:
raise CannotUpdatePassword()
else:
raise SomethingWentWrong()