Merge lp:~camptocamp/banking-addons/already_delete_reconcile_id into lp:banking-addons/bank-statement-reconcile-70

Proposed by Vincent Renaville@camptocamp
Status: Superseded
Proposed branch: lp:~camptocamp/banking-addons/already_delete_reconcile_id
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 17 lines (+5/-1)
1 file modified
account_statement_ext/account.py (+5/-1)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/already_delete_reconcile_id
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Needs Fixing
Review via email: mp+177149@code.launchpad.net

This proposal has been superseded by a proposal from 2013-11-11.

Description of the change

[FIX] prevent to delete an already deleted reconcile_id

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

I think a more efficient and straightforward way would be something along those lines:

    [...]
    reconcile_obj = self.pool.get('account.move.reconcile')
    reconcile_ids = set()
    for move_line in move.line_id:
        if move_line.reconcile_id:
            reconcile_ids.add(move_line.reconcile_id.id)
    reconcile_obj.unlink(cr, uid, list(reconcile_ids), context=context)
    return [...]

So you'll do only 1 DELETE at the end of the loop.

review: Needs Fixing
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

@Vincent, any update here please ?

Unmerged revisions

95. By Vincent Renaville@camptocamp

[FIX] prevent to delete an already deleted reconcile_id

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_ext/account.py'
2--- account_statement_ext/account.py 2012-12-20 13:37:01 +0000
3+++ account_statement_ext/account.py 2013-07-26 13:44:24 +0000
4@@ -31,8 +31,12 @@
5 Delete the reconciliation when we delete the moves. This
6 allow an easier way of cancelling the bank statement.
7 """
8+ all_ready_delete = []
9 for move in self.browse(cr, uid, ids, context=context):
10 for move_line in move.line_id:
11 if move_line.reconcile_id:
12- move_line.reconcile_id.unlink(context=context)
13+ ## We check if the reconcile is still there
14+ if move_line.reconcile_id.id not in all_ready_delete:
15+ all_ready_delete.append(move_line.reconcile_id.id)
16+ move_line.reconcile_id.unlink(context=context)
17 return super(account_move, self).unlink(cr, uid, ids, context=context)

Subscribers

People subscribed via source and target branches