diff --git a/CHANGELOG b/CHANGELOG index da77678f91..9fdbf2b438 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Unreconcile lines when cancelling statement + Version 4.4.0 - 2017-05-01 * Bug fixes (see mercurial logs for details) * Add statement line number as move description diff --git a/statement.py b/statement.py index 0b0b066bc4..ff6ffbd546 100644 --- a/statement.py +++ b/statement.py @@ -719,7 +719,14 @@ class Line(sequence_ordered(), ModelSQL, ModelView): @classmethod def delete_move(cls, lines): - Move = Pool().get('account.move') + pool = Pool() + Move = pool.get('account.move') + Reconciliation = pool.get('account.move.reconciliation') + + reconciliations = [l.reconciliation + for line in lines for l in line.move.lines + if line.move and l.reconciliation] + Reconciliation.delete(reconciliations) Move.delete(list({l.move for l in lines if l.move})) def get_move_line(self): diff --git a/tests/scenario_account_statement.rst b/tests/scenario_account_statement.rst index f26e2a523d..9cbc96b542 100644 --- a/tests/scenario_account_statement.rst +++ b/tests/scenario_account_statement.rst @@ -210,6 +210,26 @@ Validate statement:: >>> statement.state u'validated' +Cancel statement:: + + >>> statement.click('cancel') + >>> statement.state + u'cancel' + >>> filter(None, [l.move for l in statement.lines]) + [] + +Reset to draft, validate and post statement:: + + >>> statement.click('draft') + >>> statement.state + u'draft' + >>> statement.click('validate_statement') + >>> statement.state + u'validated' + >>> statement.click('post') + >>> statement.state + u'posted' + Test posted moves:: >>> statement_line = statement.lines[0]