diff --git a/mrp_production_request/models/mrp_production_request.py b/mrp_production_request/models/mrp_production_request.py index 6ac707a95..e583c90fd 100644 --- a/mrp_production_request/models/mrp_production_request.py +++ b/mrp_production_request/models/mrp_production_request.py @@ -179,8 +179,8 @@ class MrpProductionRequest(models.Model): if any([s in self._get_mo_valid_states() for s in self.mapped( 'mrp_production_ids.state')]): raise UserError( - _("You cannot reset a manufacturing request with " - "manufacturing orders not cancelled.")) + _("You cannot reset a manufacturing request if the related " + "manufacturing orders are not cancelled.")) if any([s in ['done', 'cancel'] for s in self.mapped( 'procurement_id.state')]): raise UserError( diff --git a/mrp_production_request/models/product.py b/mrp_production_request/models/product.py index 5b3be1970..9dc0bb716 100644 --- a/mrp_production_request/models/product.py +++ b/mrp_production_request/models/product.py @@ -10,5 +10,5 @@ class ProductTemplate(models.Model): mrp_production_request = fields.Boolean( string='Manufacturing Request', help="Check this box to generate " - "manufacturing request instead of generating requests manufacturing " - "orders from procurement.", default=False) + "manufacturing request instead of generating manufacturing orders " + "from procurement.", default=False) diff --git a/mrp_production_request/tests/test_mrp_production_request.py b/mrp_production_request/tests/test_mrp_production_request.py index 150561a99..56c1be99c 100644 --- a/mrp_production_request/tests/test_mrp_production_request.py +++ b/mrp_production_request/tests/test_mrp_production_request.py @@ -18,18 +18,23 @@ class TestMrpProductionRequest(TransactionCase): self.product = self.env.ref('product.product_product_3') self.product.mrp_production_request = True + self.test_product = self.env['product.product'].create({ + 'name': 'Test Product without BoM', + 'mrp_production_request': True, + }) + self.test_user = self.env['res.users'].create({ 'name': 'John', 'login': 'test', }) - def create_procurement(self, name): + def create_procurement(self, name, product): values = { 'name': name, 'date_planned': fields.Datetime.now(), - 'product_id': self.product.id, + 'product_id': product.id, 'product_qty': 4.0, - 'product_uom': self.product.uom_id.id, + 'product_uom': product.uom_id.id, 'warehouse_id': self.env.ref('stock.warehouse0').id, 'location_id': self.env.ref('stock.stock_location_stock').id, 'route_ids': [ @@ -39,7 +44,7 @@ class TestMrpProductionRequest(TransactionCase): def test_manufacture_request(self): """Tests manufacture request workflow.""" - proc = self.create_procurement('TEST/01') + proc = self.create_procurement('TEST/01', self.product) request = proc.mrp_production_request_id request.button_to_approve() request.button_draft() @@ -62,13 +67,15 @@ class TestMrpProductionRequest(TransactionCase): def test_cancellation_from_request(self): """Tests propagation of cancel to procurements from manufacturing request and not from manufacturing order.""" - proc = self.create_procurement('TEST/02') + proc = self.create_procurement('TEST/02', self.product) request = proc.mrp_production_request_id wiz = self.wiz_model.create({ 'mrp_production_request_id': request.id, }) wiz.mo_qty = 4.0 wiz.create_mo() + with self.assertRaises(UserError): + request.button_draft() mo = self.production_model.search([ ('mrp_production_request_id', '=', request.id)]) mo.action_cancel() @@ -78,7 +85,7 @@ class TestMrpProductionRequest(TransactionCase): def test_cancellation_from_proc(self): """Tests cancelation from procurement.""" - proc = self.create_procurement('TEST/03') + proc = self.create_procurement('TEST/03', self.product) request = proc.mrp_production_request_id self.assertNotEqual(request.state, 'cancel') proc.cancel() @@ -105,7 +112,9 @@ class TestMrpProductionRequest(TransactionCase): def test_raise_errors(self): """Tests user errors raising properly.""" - proc = self.create_procurement('TEST/05') + proc_no_bom = self.create_procurement('TEST/05', self.test_product) + self.assertEqual(proc_no_bom.state, 'exception') + proc = self.create_procurement('TEST/05', self.product) request = proc.mrp_production_request_id request.button_to_approve() proc.write({'state': 'done'}) diff --git a/mrp_production_request/wizards/mrp_production_request_create_mo.py b/mrp_production_request/wizards/mrp_production_request_create_mo.py index 3fbef3b7c..ef9529227 100644 --- a/mrp_production_request/wizards/mrp_production_request_create_mo.py +++ b/mrp_production_request/wizards/mrp_production_request_create_mo.py @@ -15,14 +15,10 @@ class MrpProductionRequestCreateMo(models.TransientModel): self.product_line_ids.unlink() res = self._prepare_lines() product_lines = res[0] - # workcenter_lines = res[1] # TODO: expand with workcenter_lines + # TODO: expand with workcenter_lines: they are in res[1]. for line in product_lines: self.env['mrp.production.request.create.mo.line'].create( self._prepare_product_line(line)) - # reset workcenter_lines in production order - # for line in workcenter_lines: - # line['production_id'] = production.id - # workcenter_line_obj.create(cr, uid, line, context) self._get_mo_qty() return {"type": "ir.actions.do_nothing"}