From 559e9aa39e16ec11250e883565fc99b2b69a552f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 29 Apr 2008 18:14:20 +0200 Subject: [PATCH] Add trigger on invoice when state changes --- invoice.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 58a5459c07..da74f8d272 100644 --- a/invoice.py +++ b/invoice.py @@ -743,6 +743,7 @@ class Invoice(OSV): context=context) def write(self, cursor, user, ids, vals, context=None): + workflow_service = LocalService('workflow') if isinstance(ids, (int, long)): ids = [ids] keys = vals.keys() @@ -751,8 +752,13 @@ class Invoice(OSV): keys.remove(key) if len(keys): self.check_modify(cursor, user, ids, context=context) - return super(Invoice, self).write(cursor, user, ids, vals, + res = super(Invoice, self).write(cursor, user, ids, vals, context=context) + if 'state' in vals and vals['state'] in ('paid', 'cancel'): + for invoice_id in ids: + workflow_service.trg_trigger(user, self._name, invoice_id, + cursor) + return res def copy(self, cursor, user, invoice_id, default=None, context=None): line_obj = self.pool.get('account.invoice.line')