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
=== modified file 'account_statement_ext/account.py'
--- account_statement_ext/account.py 2012-12-20 13:37:01 +0000
+++ account_statement_ext/account.py 2013-07-26 13:44:24 +0000
@@ -31,8 +31,12 @@
31 Delete the reconciliation when we delete the moves. This31 Delete the reconciliation when we delete the moves. This
32 allow an easier way of cancelling the bank statement.32 allow an easier way of cancelling the bank statement.
33 """33 """
34 all_ready_delete = []
34 for move in self.browse(cr, uid, ids, context=context):35 for move in self.browse(cr, uid, ids, context=context):
35 for move_line in move.line_id:36 for move_line in move.line_id:
36 if move_line.reconcile_id:37 if move_line.reconcile_id:
37 move_line.reconcile_id.unlink(context=context)38 ## We check if the reconcile is still there
39 if move_line.reconcile_id.id not in all_ready_delete:
40 all_ready_delete.append(move_line.reconcile_id.id)
41 move_line.reconcile_id.unlink(context=context)
38 return super(account_move, self).unlink(cr, uid, ids, context=context)42 return super(account_move, self).unlink(cr, uid, ids, context=context)

Subscribers

People subscribed via source and target branches