From 5de7500a414557b0d1fb7a6591fe7ceaad8a9484 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 16 Feb 2017 11:08:48 +0100 Subject: [PATCH] [FIX] sale: stuck workflow in invoice before delivery With a sale order with: - a stockable product - the `Create Invoice` policy set to `Before Delivery` After the quotation validation and the invoice validation, if the user: - cancelled the invoice, - then validated it again, - then hit `ignore exception` on the sale order - then registered the payment on the invoice The picking of the sale order was not created automatically, and the sale order was therefore stuck. Actually, it was just a write trigger that was missing: The condition for the sale order workflow to go to the next state is that the `invoiced` boolean is set to True. It was, when the invoice of the sale order was paid (after having registered the payment), but since this is a computed field, not stored, no write operation was actually performed on the sale order, and the workflow wasn't "notified" that a change occured for the `invoiced` boolean. A simple write on the sale order (e.g. in its notes) would have unblock the situation, though. This trigger ensures the worfklow to be notified when the invoice of the sale order is paid, and therefore when the `invoiced` boolean is set to `True`. opw-706591 --- addons/sale/sale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 9cf27eda1eb..a3a982bc42b 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1316,6 +1316,7 @@ class account_invoice(osv.Model): so_ids = sale_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context) for so_id in so_ids: sale_order_obj.message_post(cr, uid, so_id, body=_("Invoice paid"), context=context) + workflow.trg_write(uid, 'sale.order', so_id, cr) return res def unlink(self, cr, uid, ids, context=None):