From ad523cba58b76d69a484c769fb7226fad1ab41cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 29 Sep 2014 22:08:48 +0200 Subject: [PATCH] [IMP] workflow triggers when unreconciling move lines too As the workflows listening on account_move_line are triggered upon reconciliation, it makes sens to trigger them upon unreconcile too. --- .../model/__init__.py | 1 + .../model/account_move_reconcile.py | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 account_banking_payment_transfer/model/account_move_reconcile.py diff --git a/account_banking_payment_transfer/model/__init__.py b/account_banking_payment_transfer/model/__init__.py index 9069347e8..ce4014976 100644 --- a/account_banking_payment_transfer/model/__init__.py +++ b/account_banking_payment_transfer/model/__init__.py @@ -2,3 +2,4 @@ from . import account_payment from . import payment_line from . import payment_mode from . import payment_order_create +from . import account_move_reconcile diff --git a/account_banking_payment_transfer/model/account_move_reconcile.py b/account_banking_payment_transfer/model/account_move_reconcile.py new file mode 100644 index 000000000..49f4f59ef --- /dev/null +++ b/account_banking_payment_transfer/model/account_move_reconcile.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 ACSONE SA (). +# +# All other contributions are (C) by their respective contributors +# +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm +from openerp import workflow + + +class AccountMoveReconcile(orm.Model): + + _inherit = 'account.move.reconcile' + + def unlink(self, cr, uid, ids, context=None): + """ workflow triggers upon unreconcile + + This should go into the core""" + line_ids = [] + for reconcile in self.browse(cr, uid, ids, context=context): + for move_line in reconcile.line_id: + line_ids.append(move_line.id) + res = super(AccountMoveReconcile, self).\ + unlink(cr, uid, ids, context=context) + for line_id in line_ids: + workflow.trg_trigger(uid, 'account.move.line', line_id, cr) + return res