[FIX] account_voucher: fixed the case of supplier payments

bzr revid: qdp-launchpad@openerp.com-20110825174201-23wury3dpocfig3y
This commit is contained in:
Quentin (OpenERP) 2011-08-25 19:42:01 +02:00
parent 9ec72669ed
commit f3003d4143
2 changed files with 8 additions and 4 deletions

View File

@ -150,6 +150,7 @@ class account_voucher(osv.osv):
context = {}
currency_pool = self.pool.get('res.currency')
ctx = context.copy()
voucher_type = context.get('type', False)
counter_for_writeoff = counter_for_currency_diff = real_amount = 0.0
ctx.update({'date': voucher_date})
for l in line_dr_ids:
@ -182,7 +183,8 @@ class account_voucher(osv.osv):
real_amount += amount_in_company_currency
counter_for_writeoff += l.get('voucher_currency_id') == l.get('currency_id') and l['amount'] or amount_in_voucher_currency
counter_for_currency_diff += currency_pool.compute(cr, uid, l['currency_id'], l['company_currency_id'], l['amount'], context=ctx)
writeoff_amount = amount - counter_for_writeoff
sign = voucher_type in ['sale','receipt'] and 1 or -1
writeoff_amount = (sign * amount) - counter_for_writeoff
currency_rate_difference = real_amount - counter_for_currency_diff
return writeoff_amount, currency_rate_difference
@ -213,7 +215,8 @@ class account_voucher(osv.osv):
real_amount += l.amount_in_company_currency
counter_for_writeoff += (l.voucher_currency_id.id == l.currency_id.id) and l.amount or l.amount_in_voucher_currency
counter_for_currency_diff += currency_pool.compute(cr, uid, l.currency_id.id, voucher.company_id.currency_id.id, l.amount, context=ctx)
writeoff_amount = voucher.amount - counter_for_writeoff
sign = voucher.type in ['sale','receipt'] and 1 or -1
writeoff_amount = (sign * voucher.amount) - counter_for_writeoff
res[voucher.id]['writeoff_amount'] = writeoff_amount
res[voucher.id]['currency_rate_difference'] = real_amount - counter_for_currency_diff
return res

View File

@ -45,10 +45,11 @@ class invoice(osv.osv):
'close_after_process': True,
'invoice_type':inv.type,
'invoice_id':inv.id,
'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
'type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
}
}
invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: