Commit initial
[oeodf/todolist_ods_builder.git] / odsgen
1 #!/usr/bin/python
2 #-*- coding: utf-8 -*-
3
4 #odf : 608
5 import openerplib
6 from oe import *
7 from ods import *
8 #from getpass import getpass
9
10
11 def get_user_name(connection, user_login):
12     user_model = connection.get_model('res.users')
13     ids = user_model.search([("login", "=", user_login)])
14     if ids:
15         user_info = user_model.read(ids[0], ["name"])
16         return user_info["name"]
17     return None
18
19
20 if __name__ == '__main__':
21 #    login = raw_input('Utilisateur: ')
22 #    password = getpass('Mot de passe: ')
23
24     connection = openerplib.get_connection(
25         hostname='localhost',
26         database='testing',
27 #        login = login,
28 #        password = password
29         login = "admin",
30         password = "admin",
31     )
32
33     try:
34         connection.check_login()
35     except:
36         print('Serveur éteint ou Identifiants incorrects')
37     else:
38         print('Test sur res.user : %s' % (get_user_name(connection, 'admin') == 'Administrator'))
39         containers = get_containers(connection)
40         tasks = {c["id"]: get_tasks(connection, c["tasks"]) for c in containers}
41
42         #============================================================================
43         # _tasks = []
44         # for c in containers:
45         #    _tasks[c["id"]] = get_tasks(connection, c["tasks"])
46         #============================================================================
47
48         create_doc(containers, tasks)