[MERGE] [FIX] account unreconciliation and voucher cancelation (opw 605498)
When canceling a voucher or unreconciling move lines, make sure the linked invoice is still correct and has valid payment lines (if cancel one of two payments, should have the other one left). Forward-port from 6.0 addons revision:5094 Oh, by the way, revision 10000 ! bzr revid: mat@openerp.com-20140422104545-900yfw8gckse1iay
This commit is contained in:
commit
7d428b6430
|
@ -1023,10 +1023,14 @@ class account_move_line(osv.osv):
|
|||
part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs]
|
||||
unlink_ids += rec_ids
|
||||
unlink_ids += part_rec_ids
|
||||
all_moves = obj_move_line.search(cr, uid, ['|',('reconcile_id', 'in', unlink_ids),('reconcile_partial_id', 'in', unlink_ids)])
|
||||
all_moves = list(set(all_moves) - set(move_ids))
|
||||
if unlink_ids:
|
||||
if opening_reconciliation:
|
||||
obj_move_rec.write(cr, uid, unlink_ids, {'opening_reconciliation': False})
|
||||
obj_move_rec.unlink(cr, uid, unlink_ids)
|
||||
if all_moves:
|
||||
obj_move_line.reconcile_partial(cr, uid, all_moves, 'auto',context=context)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None, check=True):
|
||||
|
|
|
@ -951,19 +951,17 @@ 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])
|
||||
|
|
Loading…
Reference in New Issue