From c4cc8c3bba3b2ef808dcdab3fa65f84c0ad2a4f7 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 29 Sep 2010 16:55:46 +0530 Subject: [PATCH] [FIX] Account voucher: Voucher lines got wrong value when using invoice with payment terms bzr revid: mra@mra-laptop-20100929112546-7wubehkdze6u88mi --- addons/account_voucher/account_voucher.py | 6 +++++- .../wizard/account_statement_from_invoice.py | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index fc46d7ec39e..d5d15a6e6fa 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -393,7 +393,11 @@ class account_voucher(osv.osv): else: total_credit = price or 0.0 account_type = 'receivable' - ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) + + if not context.get('move_line_ids', False): + ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) + else: + ids = context['move_line_ids'] ids.reverse() moves = move_line_pool.browse(cr, uid, ids) diff --git a/addons/account_voucher/wizard/account_statement_from_invoice.py b/addons/account_voucher/wizard/account_statement_from_invoice.py index eb88ae5222c..926647afae1 100644 --- a/addons/account_voucher/wizard/account_statement_from_invoice.py +++ b/addons/account_voucher/wizard/account_statement_from_invoice.py @@ -71,9 +71,9 @@ class account_statement_from_invoice_lines(osv.osv_memory): elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id): amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id, statement.currency.id, amount, context=ctx) - + voucher_res = { 'type':(amount < 0 and 'payment' or 'receipt') , - 'name': line.name, + 'name': line.name, 'partner_id': line.partner_id.id, 'journal_id': statement.journal_id.id, 'account_id': line.account_id.id, @@ -83,7 +83,8 @@ class account_statement_from_invoice_lines(osv.osv_memory): 'amount':abs(amount), 'period_id':statement.period_id.id} voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context) - result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt')) + context.update({'move_line_ids': [line.id]}) + result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), context=context) voucher_line_dict = False if result['value']['line_ids']: for line_dict in result['value']['line_ids']: