Ujjvala Collins (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-797083-uco into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #797083 in OpenERP Addons: "deleting an invoice from accounting-invoices, 
does not reset the check mark in the Sales order, for that line"
  https://bugs.launchpad.net/openobject-addons/+bug/797083

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-797083-uco/+merge/64963

[FIX] sale:
---------------
* Overridden unlink method of invoice to fix the problem of deleting an invoice 
from accounting-invoices, does not reset the check mark in the Sales order, for 
that line. (lp:797083)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-797083-uco/+merge/64963
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-797083-uco.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-05-18 16:45:45 +0000
+++ sale/sale.py	2011-06-17 10:41:51 +0000
@@ -1168,6 +1168,26 @@
 
 sale_order_line()
 
+class account_invoice(osv.osv):
+    _inherit = "account.invoice"
+    
+    def unlink(self, cr, uid, ids, context=None):
+        order_line_obj = self.pool.get('sale.order.line')
+        wf_service = netsvc.LocalService("workflow")
+        if context is None:
+            context = {}
+        for inv in self.browse(cr, uid, ids, context=context):
+            if inv.type == 'out_invoice':
+                wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
+                if inv.invoice_line:
+                    inv_lines = [line.id for line in inv.invoice_line]
+                    cr.execute("select order_line_id from sale_order_line_invoice_rel where invoice_id in %s", (tuple(inv_lines),))
+                    line_ids = map(lambda x:x[0], cr.fetchall())
+                    order_line_obj.write(cr, uid, line_ids, {'invoiced': False}, context=context)
+        return super(account_invoice,self).unlink(cr, uid, ids, context=context)
+
+account_invoice()
+
 class sale_config_picking_policy(osv.osv_memory):
     _name = 'sale.config.picking_policy'
     _inherit = 'res.config'

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to