|
10 | 10 | from odoo import http
|
11 | 11 | from odoo.http import request
|
12 | 12 | import re
|
| 13 | +import xmlrpc.client |
13 | 14 |
|
14 | 15 | _logger = logging.getLogger(__name__)
|
15 | 16 | CORS = '*'
|
16 | 17 |
|
17 | 18 |
|
18 | 19 | class OdooApiXMLRPC(http.Controller):
|
19 | 20 | # version #
|
| 21 | + ''' |
| 22 | + import ipdb; ipdb.set_trace() |
| 23 | + bash entrypoint.sh --dev reload |
| 24 | + common = xmlrpc.client.ServerProxy('http://127.0.0.1:8069/xmlrpc/2/common') |
| 25 | + common.version() |
| 26 | + uid = common.authenticate(db, login, password, {}) |
| 27 | + ''' |
| 28 | + |
| 29 | + # def __init__(self): |
| 30 | + # super().__init__() |
| 31 | + # self.common = xmlrpc.client.ServerProxy('http://127.0.0.1:8069/xmlrpc/2/common') |
| 32 | + |
20 | 33 | @http.route('/odoo-api/common/version', type="json", auth='none', cors=CORS)
|
21 | 34 | def odoo_api_version(self, **kw):
|
22 |
| - version = odoo.release.version.split('.') |
23 |
| - # Try int ( error on Odoo 12 ) |
24 |
| - try: |
25 |
| - server_version_info = [int(version[0]), int(version[1]), 0, "final", 0] |
26 |
| - except: |
27 |
| - server_version_info = [str(version[0]), str(version[1]), 0, "final", 0] |
28 |
| - |
29 |
| - return { |
30 |
| - "server_version": version[0] + "." + version[1], |
31 |
| - "server_version_info": server_version_info, |
32 |
| - "server_serie": version[0] + "." + version[1], |
33 |
| - "protocol_version": 1, |
34 |
| - } |
| 35 | + common = xmlrpc.client.ServerProxy('http://127.0.0.1:8069/xmlrpc/2/common') |
| 36 | + return common.version() |
35 | 37 |
|
36 | 38 | # login #
|
37 | 39 | @http.route('/odoo-api/common/login', type="json", auth='none', cors=CORS)
|
38 | 40 | def odoo_api_login(self, db=None, login=None, password=None, **kw):
|
39 | 41 | try:
|
| 42 | + # uid = self.common.authenticate(db, login, password, {}) |
| 43 | + # another way : |
40 | 44 | uid = request.session.authenticate(db, login, password)
|
41 | 45 | return {
|
42 | 46 | "user_uid": uid,
|
|
0 commit comments