From 4e8735626eb913db1ff3a7c83a418ba89564128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 8 Apr 2013 23:45:02 +0200 Subject: [PATCH] Reset open_date when going back to draft Since it is possible to go back to draft for supplier invoice even if a number was set. The open_date should be reset in draft. review764002 --- invoice.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 0541dfcc91..912e0546c6 100644 --- a/invoice.py +++ b/invoice.py @@ -2,7 +2,7 @@ #this repository contains the full copyright notices and license terms. import datetime -from trytond.model import fields +from trytond.model import ModelView, Workflow, fields from trytond.pool import PoolMeta __all__ = ['Invoice'] @@ -34,6 +34,15 @@ class Invoice: 'open_date': datetime.datetime.now(), }) + @classmethod + @ModelView.button + @Workflow.transition('draft') + def draft(cls, invoices): + super(Invoice, cls).draft(invoices) + cls.write(invoices, { + 'open_date': None, + }) + @classmethod def copy(cls, invoices, default=None): if default is None: