From 792725fac9cc19286333450bc7ad450e49fc7551 Mon Sep 17 00:00:00 2001 From: "GPA(OpenERP)" <> Date: Wed, 16 Dec 2009 11:56:10 +0530 Subject: [PATCH] [FIX] Sale : SO was getting stuck when invoice is cancelled and SOL is with product. lp bug: https://launchpad.net/bugs/490965 fixed bzr revid: jvo@tinyerp.com-20091216062610-6y3fkslez7monb8n --- addons/sale/sale.py | 18 +++++++++++++++++- addons/sale/sale_workflow.xml | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index b225596b855..427a80851b5 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -440,7 +440,23 @@ class sale_order(osv.osv): self.pool.get('sale.order.line').write(cr, uid, [line.id], {'invoiced': invoiced}) self.write(cr, uid, ids, {'state': 'invoice_except', 'invoice_ids': False}) return True - + + def action_invoice_end(self, cr, uid, ids, context={}): + for order in self.browse(cr, uid, ids): + val = {'invoiced': True} + if order.state == 'invoice_except': + val['state'] = 'progress' + + for line in order.order_line: + towrite = [] + if line.state == 'exception': + towrite.append(line.id) + if towrite: + self.pool.get('sale.order.line').write(cr, uid, towrite, {'state': 'confirmed'}, context=context) + self.write(cr, uid, [order.id], val) + + return True + def action_cancel(self, cr, uid, ids, context={}): ok = True sale_order_line_obj = self.pool.get('sale.order.line') diff --git a/addons/sale/sale_workflow.xml b/addons/sale/sale_workflow.xml index 15b6f359175..6a7e7b6a8ee 100644 --- a/addons/sale/sale_workflow.xml +++ b/addons/sale/sale_workflow.xml @@ -75,7 +75,8 @@ invoice_end - dummy + function + action_invoice_end()