~mga/openobject-addons/account_india

« back to all changes in this revision

Viewing changes to product_index/product_index.py

  • Committer: Fabien Pinckaers
  • Date: 2008-12-14 16:48:05 UTC
  • Revision ID: fp@tinyerp.com-20081214164805-el7vuhu6p54ftv5y
improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        res={}
30
30
        date = context.get('date', time.strftime('%Y-%m-%d'))
31
31
        for id in ids:
32
 
            cr.execute("SELECT index_id, rate FROM product_index_rate WHERE index_id = %d AND name <= '%s' ORDER BY name desc LIMIT 1" % (id, date))
 
32
            cr.execute("SELECT index_id, rate FROM product_index_rate WHERE index_id = %s AND name <= '%s' ORDER BY name desc LIMIT 1" % (id, date))
33
33
            if cr.rowcount:
34
34
                id, rate=cr.fetchall()[0]
35
35
                res[id]=rate
61
61
    def compute(self, cr, uid, index, amount, date_from, date_to=None, round=True, context={}):
62
62
        if not date_to:
63
63
            date_to = time.strftime('%Y-%m-%d')
64
 
        cr.execute('select rate from product_index_rate where name<=%s and index_id=%d order by name desc limit 1', (date_from, index.id))
 
64
        cr.execute('select rate from product_index_rate where name<=%s and index_id=%s order by name desc limit 1', (date_from, index.id))
65
65
        ifrom = cr.rowcount and cr.fetchone()[0] or 1.0
66
 
        cr.execute('select rate from product_index_rate where name<=%s and index_id=%d order by name desc limit 1', (date_to, index.id))
 
66
        cr.execute('select rate from product_index_rate where name<=%s and index_id=%s order by name desc limit 1', (date_to, index.id))
67
67
        ito = cr.rowcount and cr.fetchone()[0] or 1.0
68
68
        val = amount * ito / ifrom
69
69
        if round: