From 04f632820bdbea4ed64ae2af95d03e66e81780ad Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 24 Mar 2014 11:34:27 +0100 Subject: [PATCH] [FIX] sale: trigger signal manual invoice for make invoices wizard (not advance) bzr revid: dle@openerp.com-20140324103427-yckncrnynvs5si8i --- addons/sale/wizard/sale_make_invoice.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py index 47716018caa..4405349b064 100644 --- a/addons/sale/wizard/sale_make_invoice.py +++ b/addons/sale/wizard/sale_make_invoice.py @@ -20,6 +20,7 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ +from openerp import netsvc class sale_make_invoice(osv.osv_memory): _name = "sale.make.invoice" @@ -46,6 +47,7 @@ class sale_make_invoice(osv.osv_memory): order_obj = self.pool.get('sale.order') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') + wf_service = netsvc.LocalService("workflow") newinv = [] if context is None: context = {} @@ -55,11 +57,13 @@ class sale_make_invoice(osv.osv_memory): raise osv.except_osv(_('Warning!'), _("You shouldn't manually invoice the following sale order %s") % (sale_order.name)) order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_invoice=data['invoice_date']) - - for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context): + orders = order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context) + for o in orders: for i in o.invoice_ids: newinv.append(i.id) - + # Dummy call to workflow, will not create another invoice but bind the new invoice to the subflow + for id in [o.id for o in orders if o.order_policy == 'manual']: + wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1') id = result and result[1] or False result = act_obj.read(cr, uid, [id], context=context)[0]