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"
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 = {}
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]