61
61
def compute(self, cr, uid, index, amount, date_from, date_to=None, round=True, context={}):
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