[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
This commit is contained in:
Martin Trigaux 2013-07-25 17:09:09 +02:00
parent bb2b020741
commit 457aceff18
1 changed files with 7 additions and 2 deletions

View File

@ -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: