summaryrefslogtreecommitdiff
path: root/addons/mrp_subcontracting/tests
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2019-09-16 15:45:01 +0000
committerSimon Lejeune <sle@openerp.com>2019-09-18 07:15:32 +0000
commitd1814891fe5e89a482476b4cd1a5700cb0b3fed3 (patch)
tree68c185ad8417b529df15a4cfa6dbf54409ace21a /addons/mrp_subcontracting/tests
parentdeeb17cef0057571986e21f2fd0d88821aaf99bd (diff)
[REF] mrp_subcontracting: manage backorder
closes odoo/odoo#37046 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Diffstat (limited to 'addons/mrp_subcontracting/tests')
-rw-r--r--addons/mrp_subcontracting/tests/test_subcontracting.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/addons/mrp_subcontracting/tests/test_subcontracting.py b/addons/mrp_subcontracting/tests/test_subcontracting.py
index 029d9e3a71f..41ffda20acd 100644
--- a/addons/mrp_subcontracting/tests/test_subcontracting.py
+++ b/addons/mrp_subcontracting/tests/test_subcontracting.py
@@ -510,6 +510,36 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
self.assertEqual(move_comp1.move_line_ids.filtered(lambda ml: not ml.product_uom_qty).lot_produced_ids.name, 'LOT F2')
self.assertEqual(move_comp2.move_line_ids.filtered(lambda ml: not ml.product_uom_qty).lot_produced_ids.name, 'LOT F2')
+ def test_flow_8(self):
+ resupply_sub_on_order_route = self.env['stock.location.route'].search([('name', '=', 'Resupply Subcontractor on Order')])
+ (self.comp1 + self.comp2).write({'route_ids': [(4, resupply_sub_on_order_route.id, None)]})
+
+ # Create a receipt picking from the subcontractor
+ picking_form = Form(self.env['stock.picking'])
+ picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
+ picking_form.partner_id = self.subcontractor_partner1
+ with picking_form.move_ids_without_package.new() as move:
+ move.product_id = self.finished
+ move.product_uom_qty = 5
+ picking_receipt = picking_form.save()
+ picking_receipt.action_confirm()
+
+ picking_receipt.move_lines.quantity_done = 3
+ backorder_wiz = picking_receipt.button_validate()
+ backorder_wiz = self.env['stock.backorder.confirmation'].browse(backorder_wiz['res_id'])
+ backorder_wiz.process()
+
+ backorder = self.env['stock.picking'].search([('backorder_id', '=', picking_receipt.id)])
+ self.assertTrue(backorder)
+ self.assertEqual(backorder.move_lines.product_uom_qty, 2)
+ subcontract_order = backorder.move_lines.move_orig_ids.production_id.filtered(lambda p: p.state != 'done')
+ self.assertTrue(subcontract_order)
+ self.assertEqual(subcontract_order.product_uom_qty, 5)
+ self.assertEqual(subcontract_order.qty_produced, 3)
+ backorder.move_lines.quantity_done = 2
+ backorder.action_done()
+ self.assertTrue(picking_receipt.move_lines.move_orig_ids.production_id.state == 'done')
+
class TestSubcontractingTracking(TransactionCase):
def setUp(self):
super(TestSubcontractingTracking, self).setUp()