[FIX] mrp: prevent suppression of bom if used in mo

The field bom_id is required on a manufacturing order and deleting a mrp.bom would block the current mo.
Restrict the suppression for manufacturing order in progress.
Fixes #3417
This commit is contained in:
Martin Trigaux 2014-11-10 15:36:40 +01:00
parent c200ffd74e
commit e27afc13cb
1 changed files with 7 additions and 0 deletions

View File

@ -379,6 +379,13 @@ class mrp_bom(osv.osv):
default.update(name=_("%s (copy)") % (bom_data['name']), bom_id=False)
return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context)
def unlink(self, cr, uid, ids, context=None):
if self.pool['mrp.production'].search(cr, uid, [
('bom_id', 'in', ids), ('state', 'not in', ['done', 'cancel'])
], context=context):
raise osv.except_osv(_('Warning!'), _('You can not delete a Bill of Material with running manufacturing orders.\nPlease close or cancel it first.'))
return super(mrp_bom, self).unlink(cr, uid, ids, context=context)
def rounding(f, r):
# TODO for trunk: log deprecation warning