From 457aceff185dd69926645451a1106cf4376f9b64 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 25 Jul 2013 17:09:09 +0200 Subject: [PATCH] [IMP] mrp: properly remove product lines and workorder lines when confirming a manufacturing order, avoid getting traceback if trying action on deleted record bzr revid: mat@openerp.com-20130725150909-ujh5xk2q2escr6a7 --- addons/mrp/mrp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 44fbaafbcfe..f7ae31e2c87 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -29,6 +29,7 @@ from openerp.tools import float_compare from openerp.tools.translate import _ from openerp import netsvc from openerp import tools +from openerp import SUPERUSER_ID #---------------------------------------------------------- # Work Centers @@ -595,8 +596,12 @@ class mrp_production(osv.osv): prod_line_obj = self.pool.get('mrp.production.product.line') workcenter_line_obj = self.pool.get('mrp.production.workcenter.line') for production in self.browse(cr, uid, ids): - cr.execute('delete from mrp_production_product_line where production_id=%s', (production.id,)) - cr.execute('delete from mrp_production_workcenter_line where production_id=%s', (production.id,)) + + p_ids = prod_line_obj.search(cr, SUPERUSER_ID, [('production_id', '=', production.id)], context=context) + prod_line_obj.unlink(cr, SUPERUSER_ID, p_ids, context=context) + w_ids = workcenter_line_obj.search(cr, SUPERUSER_ID, [('production_id', '=', production.id)], context=context) + workcenter_line_obj.unlink(cr, SUPERUSER_ID, w_ids, context=context) + bom_point = production.bom_id bom_id = production.bom_id.id if not bom_point: