# HG changeset patch
# User Houzefa Abbasbhay <houzefa.abba@xcg-consulting.fr>
# Date 1465820634 -7200
#      Mon Jun 13 14:23:54 2016 +0200
# Branch odoo8
# Node ID 5ac61bcbc5f502d4f19cba377a5fc65f8195dd20
# Parent  12b7ff5c71cf4d25dc4a75724abffd1335d9b6a5
Don't clear out the pass of the Odoo admin.
Suggested by petrus-v on <https://github.com/OCA/server-tools/pull/274>.

diff --git a/model/res_users.py b/model/res_users.py
--- a/model/res_users.py
+++ b/model/res_users.py
@@ -262,8 +262,15 @@
         ID (as they can't cohabit).
         """
 
-        if vals and vals.get('saml_uid'):
-            if not self._allow_saml_and_password():
+        # Clear out the pass when:
+        # - An SAML ID is being set.
+        # - The user is not the Odoo admin.
+        # - The "allow both" setting is disabled.
+        if (
+            vals and vals.get('saml_uid') and
+            self.id is not SUPERUSER_ID and
+            not self._allow_saml_and_password()
+        ):
                 vals.update({
                     'password': False,
                     'password_crypt': False,