-
Notifications
You must be signed in to change notification settings - Fork 2
/
odoo.passwd
39 lines (29 loc) · 1.04 KB
/
odoo.passwd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env python2
import getpass
import sys
import argparse
from oekit.oe_client_env import OEClientEnv
def main(options):
"""Main program."""
peek = OEClientEnv().get_erppeek_client()
login = options.login
new_password = getpass.getpass('New password for {}: '.format(login))
confirm_password = getpass.getpass('Confirm password for {}: '.format(login))
if new_password != confirm_password:
sys.stderr.write("Passwords mismatched\n")
sys.exit(3)
user = peek.model('res.users').get([('login', '=', login)])
chpass = peek.model('change.password.wizard').create(dict(
user_ids=[(0, False, dict(user_id=user.id, new_passwd=new_password))],
))
chpass.change_password_button()
def get_options():
"""Get options for the script."""
parser = argparse.ArgumentParser(
description="set user password",
)
parser.add_argument('login', help="the login of the user")
options = parser.parse_args()
return options
if __name__ == "__main__":
main(get_options())