credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05636
[Branch ~credativ/openobject-addons/6.1] Rev 7053: [MERGE] Fix for voucher posting bug
Merge authors:
Kinner Vachhani (kinner-vachhani)
------------------------------------------------------------
revno: 7053 [merge]
committer: Craig Gowing (credativ) <craig.gowing@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Thu 2013-11-14 07:55:23 +0000
message:
[MERGE] Fix for voucher posting bug
modified:
account_voucher/account_voucher.py
--
lp:~credativ/openobject-addons/6.1
https://code.launchpad.net/~credativ/openobject-addons/6.1
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/6.1.
To unsubscribe from this branch go to https://code.launchpad.net/~credativ/openobject-addons/6.1/+edit-subscription
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2012-12-05 17:57:01 +0000
+++ account_voucher/account_voucher.py 2013-11-11 13:36:28 +0000
@@ -767,20 +767,40 @@
return True
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):
- 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)
-
- if voucher.move_id:
+ # refresh to make sure you don't unlink an already removed move
+ voucher.refresh()
+ lines_by_rec = {}
+ for line in voucher.move_ids:
+ if line.reconcile_id:
+
+ if not lines_by_rec.get(line.reconcile_id.id):
+ lines_by_rec[line.reconcile_id.id] = []
+ for rec_line in line.reconcile_id.line_id:
+ if (rec_line.id not in lines_by_rec[line.reconcile_id.id]
+ and rec_line.id != line.id):
+ # only adding the reconciliations to keep
+ lines_by_rec[line.reconcile_id.id].append(rec_line.id)
+ if line.reconcile_partial_id:
+
+ if not lines_by_rec.get(line.reconcile_partial_id.id):
+ lines_by_rec[line.reconcile_partial_id.id] = []
+ for rec_line in line.reconcile_partial_id.line_partial_ids:
+ if (rec_line.id not in lines_by_rec[line.reconcile_partial_id.id]
+ and rec_line.id != line.id):
+ lines_by_rec[line.reconcile_partial_id.id].append(rec_line.id)
+
+ reconcile_pool.unlink(cr, uid, lines_by_rec.keys())
+
+ for rec_id in lines_by_rec:
+ if len(lines_by_rec[rec_id]) > 1:
+ move_line_pool.reconcile_partial(cr, uid, lines_by_rec[rec_id])
+ if voucher.move_id:
move_pool.button_cancel(cr, uid, [voucher.move_id.id])
move_pool.unlink(cr, uid, [voucher.move_id.id])
res = {