diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-07-16 09:14:17 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-16 09:14:17 +0000 |
| commit | cf8e74a1a7d3404f57798573e8b15ce4dc5b9be4 (patch) | |
| tree | bd95e9d20aff9b4f92550bffb2835a55c3698c27 /addons/mrp/tests/test_order.py | |
| parent | b67a3bb403b80e98a2b66dcb8cf570d2b156fb68 (diff) | |
| parent | 1bd434da34731b5467cc17fdffe6f3ed5dfea2d4 (diff) | |
[MERGE] Forward port of 12.0 to saas-12.2 up to 1bd434da34731b546
closes odoo/odoo#34901
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/mrp/tests/test_order.py')
| -rw-r--r-- | addons/mrp/tests/test_order.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index 1445e240e97..5bfbec8df12 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -5,6 +5,7 @@ from odoo.tests import Form from datetime import datetime, timedelta from odoo.fields import Datetime as Dt +from odoo.exceptions import UserError from odoo.addons.mrp.tests.common import TestMrpCommon @@ -692,6 +693,51 @@ class TestMrpOrder(TestMrpCommon): mo.button_mark_done() def test_product_produce_6(self): + """ Plan 5 finished products, reserve and produce 3. Post the current production. + Simulate an unlock and edit and, on the opened moves, set the consumed quantity + to 3. Now, try to update the quantity to produce to 3. It should fail since there + are consumed quantities. Unlock and edit, remove the consumed quantities and + update the quantity to produce to 3.""" + self.stock_location = self.env.ref('stock.stock_location_stock') + mo, bom, p_final, p1, p2 = self.generate_mo() + self.assertEqual(len(mo), 1, 'MO should have been created') + + self.env['stock.quant']._update_available_quantity(p1, self.stock_location, 20) + + self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 5) + mo.action_assign() + + produce_wizard = self.env['mrp.product.produce'].with_context({ + 'active_id': mo.id, + 'active_ids': [mo.id], + }).create({ + 'product_qty': 3.0, + }) + produce_wizard._onchange_product_qty() + produce_wizard.do_produce() + + mo.post_inventory() + self.assertEqual(len(mo.move_raw_ids), 4) + + mo.move_raw_ids.filtered(lambda m: m.state != 'done')[0].quantity_done = 3 + + update_quantity_wizard = self.env['change.production.qty'].create({ + 'mo_id': mo.id, + 'product_qty': 3, + }) + with self.assertRaises(UserError): + update_quantity_wizard.change_prod_qty() + + mo.move_raw_ids.filtered(lambda m: m.state != 'done')[0].quantity_done = 0 + update_quantity_wizard.change_prod_qty() + + self.assertEqual(len(mo.move_raw_ids), 2) + + mo.button_mark_done() + self.assertTrue(all(s == 'done' for s in mo.move_raw_ids.mapped('state'))) + self.assertEqual(sum(mo.move_raw_ids.mapped('move_line_ids.product_uom_qty')), 0) + + def test_product_produce_6(self): """ Build some final products and change the quantity to produce directly in the wizard. The component line should be updated . """ |
