4
4
5
5
Author: Florent Xicluna
6
6
"""
7
+ import _ast
7
8
import atexit
8
9
import csv
9
10
import functools
16
17
import time
17
18
import traceback
18
19
19
- import _ast
20
20
21
21
PY2 = sys .version_info [0 ] == 2
22
22
if not PY2 : # Python 3
23
23
from configparser import ConfigParser
24
24
from threading import current_thread
25
25
from urllib .request import Request , urlopen
26
- from xmlrpc .client import Fault , ServerProxy , MININT , MAXINT
26
+ from xmlrpc .client import MAXINT , MININT , Fault , ServerProxy
27
27
else : # Python 2
28
- from ConfigParser import SafeConfigParser as ConfigParser
29
28
from threading import currentThread as current_thread
29
+
30
+ from ConfigParser import SafeConfigParser as ConfigParser
30
31
from urllib2 import Request , urlopen
31
- from xmlrpclib import Fault , ServerProxy , MININT , MAXINT
32
+ from xmlrpclib import MAXINT , MININT , Fault , ServerProxy
32
33
33
34
try :
34
35
import requests
@@ -166,7 +167,6 @@ def _dict_to_list(self, rowdict):
166
167
for cell in rowlst
167
168
]
168
169
169
-
170
170
else : # Python 3
171
171
basestring = str
172
172
int_types = int
@@ -441,7 +441,6 @@ def http_post(url, data, headers={"Content-Type": "application/json"}):
441
441
resp = requests .post (url , data = data , headers = headers )
442
442
return resp .json ()
443
443
444
-
445
444
else :
446
445
447
446
def http_post (url , data , headers = {"Content-Type" : "application/json" }):
@@ -455,12 +454,12 @@ def dispatch_jsonrpc(url, service_name, method, args):
455
454
"jsonrpc" : "2.0" ,
456
455
"method" : "call" ,
457
456
"params" : {"service" : service_name , "method" : method , "args" : args },
458
- "id" : "%04x%010x" % (os .getpid (), (int (time .time () * 1e6 ) % 2 ** 40 )),
457
+ "id" : "%04x%010x" % (os .getpid (), (int (time .time () * 1e6 ) % 2 ** 40 )),
459
458
}
460
459
resp = http_post (url , json .dumps (data ).encode ("ascii" ))
461
460
if resp .get ("error" ):
462
461
raise ServerError (resp ["error" ])
463
- return resp [ "result" ]
462
+ return resp . get ( "result" )
464
463
465
464
466
465
class partial (functools .partial ):
@@ -544,13 +543,13 @@ def wrapper(self, *args):
544
543
class Env (object ):
545
544
"""An environment wraps data for Odoo models and records:
546
545
547
- - :attr:`db_name`, the current database;
548
- - :attr:`uid`, the current user id;
549
- - :attr:`context`, the current context dictionary.
546
+ - :attr:`db_name`, the current database;
547
+ - :attr:`uid`, the current user id;
548
+ - :attr:`context`, the current context dictionary.
550
549
551
- To retrieve an instance of ``some.model``:
550
+ To retrieve an instance of ``some.model``:
552
551
553
- >>> env["some.model"]
552
+ >>> env["some.model"]
554
553
"""
555
554
556
555
name = uid = user = None
@@ -1953,7 +1952,12 @@ def _set_external_id(self, xml_id):
1953
1952
if self .env ["ir.model.data" ].search (domain ):
1954
1953
raise ValueError ("ID %r collides with another entry" % xml_id )
1955
1954
self .env ["ir.model.data" ].create (
1956
- {"model" : self ._name , "res_id" : self .id , "module" : mod , "name" : name ,}
1955
+ {
1956
+ "model" : self ._name ,
1957
+ "res_id" : self .id ,
1958
+ "module" : mod ,
1959
+ "name" : name ,
1960
+ }
1957
1961
)
1958
1962
1959
1963
def __getattr__ (self , attr ):
0 commit comments