diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index c488ebe54d2..4fb810809cc 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -51,7 +51,8 @@ class StockRule(models.Model): for company_id, productions_values in productions_values_by_company.items(): # create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example) productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(productions_values) - productions.filtered(lambda p: not p.orderpoint_id or not p.move_raw_ids).action_confirm() + productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or\ + (p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm() for production in productions: origin_production = production.move_dest_ids and production.move_dest_ids[0].raw_material_production_id or False diff --git a/addons/mrp/tests/test_procurement.py b/addons/mrp/tests/test_procurement.py index e37580d67d9..98449ac845a 100644 --- a/addons/mrp/tests/test_procurement.py +++ b/addons/mrp/tests/test_procurement.py @@ -298,7 +298,7 @@ class TestProcurement(TestMrpCommon): def test_procurement_with_empty_bom(self): """Ensure that a procurement request using a product with an empty BoM - will create an empty MO in confirmed state that can be completed afterwards. + will create an empty MO in draft state that can be completed afterwards. """ self.warehouse = self.env.ref('stock.warehouse0') route_manufacture = self.warehouse.manufacture_pull_id.route_id.id @@ -328,7 +328,7 @@ class TestProcurement(TestMrpCommon): production = self.env['mrp.production'].search([('product_id', '=', product.id)]) self.assertTrue(production) self.assertFalse(production.move_raw_ids) - self.assertEqual(production.state, 'confirmed') + self.assertEqual(production.state, 'draft') comp1 = self.env['product.product'].create({ 'name': 'egg',