diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index fcab8f82015..8032cad2b60 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -68,17 +68,6 @@ class MrpBom(models.Model): for line in self.bom_line_ids: line.attribute_value_ids = False - @api.multi - def write(self, values): - mos = self.env['mrp.production'].search_count([ - ('bom_id', 'in', self.ids), - ('state', 'not in', ['done', 'cancel']) - ]) - if mos and any(k not in ['code', 'sequence', 'pick_type_id', 'ready_to_produce'] for k in values.keys()): - raise ValidationError(_('This BoM is used in some Manufacturing Orders that are still open. You should rather archive this BoM and create a new one.')) - return super(MrpBom, self).write(values) - - @api.constrains('product_id', 'product_tmpl_id', 'bom_line_ids') def _check_product_recursion(self): for bom in self: diff --git a/addons/mrp/tests/test_bom.py b/addons/mrp/tests/test_bom.py index 354babff84a..44fd56b6431 100644 --- a/addons/mrp/tests/test_bom.py +++ b/addons/mrp/tests/test_bom.py @@ -228,19 +228,3 @@ class TestBoM(TestMrpCommon): }) # Check consumed materials in production order. self.assertEqual(mrp_order.move_raw_ids.mapped('product_id').ids, consu_product_ids) - - def test_update_bom(self): - """Update a BoM used in open production should raise an error""" - mo = self.env['mrp.production'].create({ - 'name': 'MO 1', - 'product_id': self.product_1.id, - 'product_uom_id': self.product_1.uom_id.id, - 'product_qty': 2, - 'bom_id': self.bom_1.id, - }) - mo.button_plan() - # update an authorized field - self.bom_1.write({'code': 'Hello'}) - # update a not authorized field - with self.assertRaises(exceptions.ValidationError): - self.bom_1.write({'product_id': self.product_2.id}) diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py index 4066a8d33ab..49df9007835 100644 --- a/addons/mrp/tests/test_workorder_operation.py +++ b/addons/mrp/tests/test_workorder_operation.py @@ -124,7 +124,7 @@ class TestWorkOrderProcess(common.TransactionCase): self.env['stock.move'].search([('product_id', '=', product_bolt.id)])._do_unreserve() product_bolt.type = 'product' - bom = self.env['mrp.bom'].browse(self.ref("mrp.mrp_bom_desk")).copy() + bom = self.env['mrp.bom'].browse(self.ref("mrp.mrp_bom_desk")) bom.routing_id = self.ref('mrp.mrp_routing_1') bom.bom_line_ids.filtered(lambda p: p.product_id == product_table_sheet).operation_id = bom.routing_id.operation_ids[0]