changeset 3:df5021a533c3

Set invoice state in waiting When no invoice has been generated and the invoice method is remaining, the state should be waiting otherwise the sale become done.
author Cédric Krier <ced@b2ck.com>
date Mon, 05 Mar 2018 15:45:36 +0100
parents cd9d1c2cabf8
children 1484d970c7f4
files sale_invoice_method_remaining/sale.py tests/scenario_sale_invoice_method_remaining.rst
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sale_invoice_method_remaining/sale.py	Mon Mar 05 15:38:15 2018 +0100
+++ b/sale_invoice_method_remaining/sale.py	Mon Mar 05 15:45:36 2018 +0100
@@ -43,6 +43,12 @@
             return
         return super(Sale, self).create_invoice()
 
+    def get_invoice_state(self):
+        state = super(Sale, self).get_invoice_state()
+        if state == 'none' and self.invoice_method == 'remaining':
+            state = 'waiting'
+        return state
+
 
 class Line:
     __metaclass__ = PoolMeta
--- a/tests/scenario_sale_invoice_method_remaining.rst	Mon Mar 05 15:38:15 2018 +0100
+++ b/tests/scenario_sale_invoice_method_remaining.rst	Mon Mar 05 15:45:36 2018 +0100
@@ -80,6 +80,8 @@
     >>> sale.click('process')
     >>> len(sale.invoices)
     0
+    >>> sale.state
+    u'processing'
 
 Invoice remaining::