|
30 | 30 |
|
31 | 31 | __author__ = "Pedro Gracia <[email protected]>"
|
32 | 32 | __license__ = "GPLv3+"
|
33 |
| -__version__ = "0.2.3" |
| 33 | +__version__ = "0.3.0" |
34 | 34 |
|
35 | 35 |
|
36 | 36 | OOOPMODELS = 'ir.model'
|
@@ -208,11 +208,11 @@ def read_all(self, model, fields=[]):
|
208 | 208 | print "DEBUG [read_all]:", model, fields
|
209 | 209 | return self.objectsock.execute(self.dbname, self.uid, self.pwd, model, 'read', self.all(model), fields, self.context)
|
210 | 210 |
|
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): |
212 | 212 | """ return ids that match with 'query' """
|
213 | 213 | if self.debug:
|
214 | 214 | 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) |
216 | 216 |
|
217 | 217 | # TODO: verify if remove this
|
218 | 218 | def custom_execute(self, model, ids, remote_method, data):
|
@@ -658,16 +658,19 @@ def __getattr__(self, field):
|
658 | 658 | raise AttributeError('field \'%s\' is not defined' % field)
|
659 | 659 | ttype = self.fields[field]['ttype']
|
660 | 660 | relation = self.fields[field]['relation']
|
| 661 | + assert(isinstance(data, list) and len(data) == 1) |
| 662 | + data = data[0] |
661 | 663 | if ttype == 'many2one':
|
662 | 664 | if data[name]: # TODO: review this
|
663 | 665 | 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]) |
665 | 668 | if key in self.INSTANCES.keys():
|
666 | 669 | self.__dict__[name] = self.INSTANCES[key]
|
667 | 670 | else:
|
668 | 671 | # TODO: use a Manager instance, not Data
|
669 | 672 | instance = Data(Manager(relation, self._ooop),
|
670 |
| - data[name][0], relation, data=self) |
| 673 | + data[name], relation, data=self) |
671 | 674 | self.__dict__[name] = instance
|
672 | 675 | self.INSTANCES[key] = instance
|
673 | 676 | else:
|
|
0 commit comments