From 26f807fa025ca99a9d0cf4e0212d395bb726d570 Mon Sep 17 00:00:00 2001 From: Amit Dodiya Date: Tue, 25 Mar 2014 11:17:43 +0530 Subject: [PATCH] [FIX] account_voucher: forward port of 6.0 revision: 5094, for issue cancel_voucher method is unlinking the whole account_move_reconciliation record bzr revid: ado@tinyerp.com-20140325054743-opywyna9w1toyjp8 --- addons/account_voucher/account_voucher.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index f58c640b11c..86755ce17b6 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -947,19 +947,15 @@ class account_voucher(osv.osv): def cancel_voucher(self, cr, uid, ids, context=None): reconcile_pool = self.pool.get('account.move.reconcile') move_pool = self.pool.get('account.move') - + move_line_pool = self.pool.get('account.move.line') for voucher in self.browse(cr, uid, ids, context=context): - # refresh to make sure you don't unlink an already removed move - voucher.refresh() - recs = [] for line in voucher.move_ids: if line.reconcile_id: - recs += [line.reconcile_id.id] - if line.reconcile_partial_id: - recs += [line.reconcile_partial_id.id] - - reconcile_pool.unlink(cr, uid, recs) - + move_lines = [move_line.id for move_line in line.reconcile_id.line_id] + move_lines.remove(line.id) + reconcile_pool.unlink(cr, uid, [line.reconcile_id.id]) + if len(move_lines) >= 2: + move_line_pool.reconcile_partial(cr, uid, move_lines, 'auto',context=context) if voucher.move_id: move_pool.button_cancel(cr, uid, [voucher.move_id.id]) move_pool.unlink(cr, uid, [voucher.move_id.id])