~openerp/openobject-server/trunk-speedup-need_action-tde

« back to all changes in this revision

Viewing changes to bin/osv/fields.py

  • Committer: Harry (Open ERP)
  • Author(s): xrg
  • Date: 2009-11-20 14:31:04 UTC
  • mfrom: (1119.1.208)
  • mto: (1898.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1900.
  • Revision ID: hmo@tinyerp.com-20091120143104-tb6136unkdw7yfy9
[merge] merge from lp:~xrg/openobject-server/optimize-5.0 and removed some confilts

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
            elif act[0] == 6:
460
460
                obj.write(cr, user, act[2], {self._fields_id:id}, context=context or {})
461
461
                ids2 = act[2] or [0]
462
 
                cr.execute('select id from '+_table+' where '+self._fields_id+'=%s and id not in ('+','.join(map(str, ids2))+')', (id,))
 
462
                cr.execute('select id from '+_table+' where '+self._fields_id+'=%s and id <> ALL (%s)', (id,ids2))
463
463
                ids3 = map(lambda x:x[0], cr.fetchall())
464
464
                obj.write(cr, user, ids3, {self._fields_id:False}, context=context or {})
465
465
        return result
504
504
            return res
505
505
        for id in ids:
506
506
            res[id] = []
507
 
        ids_s = ','.join(map(str, ids))
508
507
        limit_str = self._limit is not None and ' limit %d' % self._limit or ''
509
508
        obj = obj.pool.get(self._obj)
510
509
 
514
513
 
515
514
        cr.execute('SELECT '+self._rel+'.'+self._id2+','+self._rel+'.'+self._id1+' \
516
515
                FROM '+self._rel+' , '+obj._table+' \
517
 
                WHERE '+self._rel+'.'+self._id1+' in ('+ids_s+') \
 
516
                WHERE '+self._rel+'.'+self._id1+' = ANY (%s) \
518
517
                    AND '+self._rel+'.'+self._id2+' = '+obj._table+'.id '+d1
519
518
                +limit_str+' order by '+obj._table+'.'+obj._order+' offset %s',
520
 
                d2+[offset])
 
519
                [ids,]+d2+[offset])
521
520
        for r in cr.fetchall():
522
521
            res[r[1]].append(r[0])
523
522
        return res
585
584
                obj.datas[id][name] = act[2]
586
585
 
587
586
 
 
587
def get_nice_size(a):
 
588
        (x,y) = a
 
589
        if isinstance(y, (int,long)):
 
590
                size = y
 
591
        elif y:
 
592
                y = len(y)
 
593
        else:
 
594
                y = 0
 
595
        return (x, tools.human_size(size))
 
596
 
588
597
# ---------------------------------------------------------
589
598
# Function fields
590
599
# ---------------------------------------------------------
665
674
            
666
675
        if self._type == 'binary' and context.get('bin_size', False):
667
676
            # convert the data returned by the function with the size of that data...
668
 
            res = dict(map(lambda (x, y): (x, tools.human_size(len(y or ''))), res.items()))
 
677
            res = dict(map( get_nice_size, res.items()))
669
678
        return res
670
679
    get_memory = get
671
680