diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 2571c83b848..428cb627404 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -74,6 +74,8 @@ class MrpProductProduce(models.TransientModel): # Nothing to do for lots since values are created using default data (stock.move.lots) moves = self.production_id.move_raw_ids quantity = self.product_qty + if float_compare(quantity, 0, precision_rounding=self.product_uom_id.rounding) <= 0: + raise UserError(_('You should at least produce some quantity')) for move in moves.filtered(lambda x: x.product_id.tracking == 'none' and x.state not in ('done', 'cancel')): if move.unit_factor: move.quantity_done_store += quantity * move.unit_factor @@ -84,6 +86,8 @@ class MrpProductProduce(models.TransientModel): elif move.unit_factor: move.quantity_done_store += quantity * move.unit_factor self.check_finished_move_lots() + if self.production_id.state == 'confirmed': + self.production_id.state = 'progress' return {'type': 'ir.actions.act_window_close'} @api.multi diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index 74d1da1e8f8..d7ba640023c 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -280,7 +280,7 @@ class TestSaleMrpFlow(common.TransactionCase): mnf_product_d.post_inventory() # Check state of manufacturing order. - self.assertEqual(mnf_product_d.state, 'confirmed', 'Manufacturing order should still be in confirmed state.') + self.assertEqual(mnf_product_d.state, 'progress', 'Manufacturing order should still be in progress state.') # Check available quantity of product D. self.assertEqual(product_d.qty_available, 20, 'Wrong quantity available of product D.') @@ -332,7 +332,7 @@ class TestSaleMrpFlow(common.TransactionCase): mnf_product_a.post_inventory() # Check state of manufacturing order product A. - self.assertEqual(mnf_product_a.state, 'confirmed', 'Manufacturing order should still be in confirmed state.') + self.assertEqual(mnf_product_a.state, 'progress', 'Manufacturing order should still be in the progress state.') # Check product A avaialble quantity should be 120. self.assertEqual(product_a.qty_available, 120, 'Wrong quantity available of product A.')