Skip to content

Commit 296c202

Browse files
committed
fix: compatibility with 11.0
1 parent 24ac54a commit 296c202

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ooop.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
__author__ = "Pedro Gracia <[email protected]>"
3232
__license__ = "GPLv3+"
33-
__version__ = "0.2.3"
33+
__version__ = "0.3.0"
3434

3535

3636
OOOPMODELS = 'ir.model'
@@ -208,11 +208,11 @@ def read_all(self, model, fields=[]):
208208
print "DEBUG [read_all]:", model, fields
209209
return self.objectsock.execute(self.dbname, self.uid, self.pwd, model, 'read', self.all(model), fields, self.context)
210210

211-
def search(self, model, query, offset=0, limit=None, order=None):
211+
def search(self, model, query, offset=0, limit=None, order=None, count=False):
212212
""" return ids that match with 'query' """
213213
if self.debug:
214214
print "DEBUG [search]:", model, query, offset, limit, order
215-
return self.objectsock.execute(self.dbname, self.uid, self.pwd, model, 'search', query, offset, limit, order, self.context)
215+
return self.objectsock.execute(self.dbname, self.uid, self.pwd, model, 'search', query, offset, limit, order, count, self.context)
216216

217217
# TODO: verify if remove this
218218
def custom_execute(self, model, ids, remote_method, data):
@@ -658,16 +658,19 @@ def __getattr__(self, field):
658658
raise AttributeError('field \'%s\' is not defined' % field)
659659
ttype = self.fields[field]['ttype']
660660
relation = self.fields[field]['relation']
661+
assert(isinstance(data, list) and len(data) == 1)
662+
data = data[0]
661663
if ttype == 'many2one':
662664
if data[name]: # TODO: review this
663665
self.__dict__['__%s' % name] = data[name]
664-
key = '%s:%i' % (relation, data[name][0])
666+
assert(isinstance(data[name], int))
667+
key = '%s:%i' % (relation, data[name])
665668
if key in self.INSTANCES.keys():
666669
self.__dict__[name] = self.INSTANCES[key]
667670
else:
668671
# TODO: use a Manager instance, not Data
669672
instance = Data(Manager(relation, self._ooop),
670-
data[name][0], relation, data=self)
673+
data[name], relation, data=self)
671674
self.__dict__[name] = instance
672675
self.INSTANCES[key] = instance
673676
else:

0 commit comments

Comments
 (0)