def setUp(self): super(TestMultistepManufacturing, self).setUp() self.MrpProduction = self.env['mrp.production'] # Create warehouse warehouse_form = Form(self.env['stock.warehouse']) warehouse_form.name = 'Test' warehouse_form.code = 'Test' self.warehouse = warehouse_form.save() self.uom_unit = self.env.ref('uom.product_uom_unit') # Create manufactured product product_form = Form(self.env['product.product']) product_form.name = 'Stick' product_form.uom_id = self.uom_unit product_form.uom_po_id = self.uom_unit product_form.route_ids.clear() product_form.route_ids.add(self.warehouse.manufacture_pull_id.route_id) product_form.route_ids.add(self.warehouse.mto_pull_id.route_id) self.product_manu = product_form.save() # Create raw product for manufactured product product_form = Form(self.env['product.product']) product_form.name = 'Raw Stick' product_form.uom_id = self.uom_unit product_form.uom_po_id = self.uom_unit self.product_raw = product_form.save() # Create bom for manufactured product bom_product_form = Form(self.env['mrp.bom']) bom_product_form.product_id = self.product_manu bom_product_form.product_tmpl_id = self.product_manu.product_tmpl_id bom_product_form.product_qty = 1.0 bom_product_form.type = 'normal' with bom_product_form.bom_line_ids.new() as bom_line: bom_line.product_id = self.product_raw bom_line.product_qty = 2.0 self.bom_prod_manu = bom_product_form.save() # Create sale order sale_form = Form(self.env['sale.order']) sale_form.partner_id = self.env.ref('base.res_partner_1') sale_form.picking_policy = 'direct' sale_form.warehouse_id = self.warehouse with sale_form.order_line.new() as line: line.name = self.product_manu.name line.product_id = self.product_manu line.product_uom_qty = 1.0 line.product_uom = self.uom_unit line.price_unit = 10.0 self.sale_order = sale_form.save()
def setUp(self): super(TestMultistepManufacturingWarehouse, self).setUp() # Create warehouse self.customer_location = self.env['ir.model.data'].xmlid_to_res_id('stock.stock_location_customers') warehouse_form = Form(self.env['stock.warehouse']) warehouse_form.name = 'Test Warehouse' warehouse_form.code = 'TWH' self.warehouse = warehouse_form.save() self.uom_unit = self.env.ref('uom.product_uom_unit') # Create manufactured product product_form = Form(self.env['product.product']) product_form.name = 'Stick' product_form.uom_id = self.uom_unit product_form.uom_po_id = self.uom_unit product_form.type = 'product' product_form.route_ids.clear() product_form.route_ids.add(self.warehouse.manufacture_pull_id.route_id) product_form.route_ids.add(self.warehouse.mto_pull_id.route_id) self.finished_product = product_form.save() # Create raw product for manufactured product product_form = Form(self.env['product.product']) product_form.name = 'Raw Stick' product_form.type = 'product' product_form.uom_id = self.uom_unit product_form.uom_po_id = self.uom_unit self.raw_product = product_form.save() # Create bom for manufactured product bom_product_form = Form(self.env['mrp.bom']) bom_product_form.product_id = self.finished_product bom_product_form.product_tmpl_id = self.finished_product.product_tmpl_id bom_product_form.product_qty = 1.0 bom_product_form.type = 'normal' with bom_product_form.bom_line_ids.new() as bom_line: bom_line.product_id = self.raw_product bom_line.product_qty = 2.0 self.bom = bom_product_form.save()
def test_toggle_active_warehouse_2(self): wh = Form(self.env['stock.warehouse']) wh.name = "The attic of Willy" wh.code = "WIL" wh.reception_steps = "two_steps" wh.delivery_steps = "pick_pack_ship" warehouse = wh.save() warehouse.resupply_wh_ids = [(6, 0, [self.warehouse_1.id])] custom_location = Form(self.env['stock.location']) custom_location.name = "A Trunk" custom_location.location_id = warehouse.lot_stock_id custom_location = custom_location.save() # Add a warehouse on the route. warehouse.reception_route_id.write({ 'warehouse_ids': [(4, self.warehouse_1.id)] }) route = Form(self.env['stock.location.route']) route.name = "Stair" route = route.save() route.warehouse_ids = [(6, 0, [warehouse.id, self.warehouse_1.id])] # Pre archive a location and a route warehouse.delivery_route_id.toggle_active() warehouse.wh_pack_stock_loc_id.toggle_active() # Archive warehouse warehouse.toggle_active() # Global rule self.assertFalse(warehouse.mto_pull_id.active) # Route self.assertTrue(warehouse.reception_route_id.active) self.assertFalse(warehouse.delivery_route_id.active) self.assertTrue(route.active) # Location self.assertFalse(warehouse.lot_stock_id.active) self.assertFalse(warehouse.wh_input_stock_loc_id.active) self.assertFalse(warehouse.wh_qc_stock_loc_id.active) self.assertFalse(warehouse.wh_output_stock_loc_id.active) self.assertFalse(warehouse.wh_pack_stock_loc_id.active) self.assertFalse(custom_location.active) # Picking Type self.assertFalse(warehouse.in_type_id.active) self.assertFalse(warehouse.out_type_id.active) self.assertFalse(warehouse.int_type_id.active) self.assertFalse(warehouse.pick_type_id.active) self.assertFalse(warehouse.pack_type_id.active) # Active warehouse warehouse.toggle_active() # Global rule self.assertTrue(warehouse.mto_pull_id.active) # Route self.assertTrue(warehouse.reception_route_id.active) self.assertTrue(warehouse.delivery_route_id.active) # Location self.assertTrue(warehouse.lot_stock_id.active) self.assertTrue(warehouse.wh_input_stock_loc_id.active) self.assertFalse(warehouse.wh_qc_stock_loc_id.active) self.assertTrue(warehouse.wh_output_stock_loc_id.active) self.assertTrue(warehouse.wh_pack_stock_loc_id.active) self.assertTrue(custom_location.active) # Picking Type self.assertTrue(warehouse.in_type_id.active) self.assertTrue(warehouse.out_type_id.active) self.assertTrue(warehouse.int_type_id.active) self.assertTrue(warehouse.pick_type_id.active) self.assertTrue(warehouse.pack_type_id.active)
def test_toggle_active_warehouse_1(self): """ Basic test that create a warehouse with classic configuration. Archive it and check that locations, picking types, routes, rules are correclty active or archive. """ wh = Form(self.env['stock.warehouse']) wh.name = "The attic of Willy" wh.code = "WIL" warehouse = wh.save() custom_location = Form(self.env['stock.location']) custom_location.name = "A Trunk" custom_location.location_id = warehouse.lot_stock_id custom_location = custom_location.save() # Archive warehouse warehouse.toggle_active() # Global rule self.assertFalse(warehouse.mto_pull_id.active) # Route self.assertFalse(warehouse.reception_route_id.active) self.assertFalse(warehouse.delivery_route_id.active) # Location self.assertFalse(warehouse.lot_stock_id.active) self.assertFalse(warehouse.wh_input_stock_loc_id.active) self.assertFalse(warehouse.wh_qc_stock_loc_id.active) self.assertFalse(warehouse.wh_output_stock_loc_id.active) self.assertFalse(warehouse.wh_pack_stock_loc_id.active) self.assertFalse(custom_location.active) # Picking Type self.assertFalse(warehouse.in_type_id.active) self.assertFalse(warehouse.out_type_id.active) self.assertFalse(warehouse.int_type_id.active) self.assertFalse(warehouse.pick_type_id.active) self.assertFalse(warehouse.pack_type_id.active) # Active warehouse warehouse.toggle_active() # Global rule self.assertTrue(warehouse.mto_pull_id.active) # Route self.assertTrue(warehouse.reception_route_id.active) self.assertTrue(warehouse.delivery_route_id.active) # Location self.assertTrue(warehouse.lot_stock_id.active) self.assertFalse(warehouse.wh_input_stock_loc_id.active) self.assertFalse(warehouse.wh_qc_stock_loc_id.active) self.assertFalse(warehouse.wh_output_stock_loc_id.active) self.assertFalse(warehouse.wh_pack_stock_loc_id.active) self.assertTrue(custom_location.active) # Picking Type self.assertTrue(warehouse.in_type_id.active) self.assertTrue(warehouse.out_type_id.active) self.assertTrue(warehouse.int_type_id.active) self.assertFalse(warehouse.pick_type_id.active) self.assertFalse(warehouse.pack_type_id.active)
def test_00_crossdock(self): # Create a supplier supplier_crossdock = self.env['res.partner'].create( {'name': "Crossdocking supplier"}) # I first create a warehouse with pick-pack-ship and reception in 2 steps wh_f = Form(self.env['stock.warehouse']) wh_f.name = 'WareHouse PickPackShip' wh_f.code = 'whpps' wh_f.reception_steps = 'two_steps' wh_f.delivery_steps = 'pick_pack_ship' wh_pps = wh_f.save() # Check that cross-dock route is active self.assertTrue( wh_pps.crossdock_route_id.active, "Crossdock route should be active when reception_steps is not in 'single_step'" ) p_f = Form(self.env['product.template']) p_f.name = 'PCE' p_f.type = 'product' p_f.categ_id = self.env.ref('product.product_category_1') p_f.list_price = 100.0 with p_f.seller_ids.new() as seller: seller.name = supplier_crossdock p_f.route_ids.add(wh_pps.crossdock_route_id) cross_shop_product = p_f.save() std_price_wiz = Form( self.env['stock.change.standard.price'].with_context( active_id=p_f.id, active_model='product.template')) std_price_wiz.new_price = 70.0 std_price_wiz.save() # Create a sales order with a line of 100 PCE incoming shipment with route_id crossdock shipping so_form = Form(self.env['sale.order']) so_form.partner_id = self.env.ref('base.res_partner_4') so_form.warehouse_id = wh_pps with mute_logger('harpiya.tests.common.onchange'): # otherwise complains that there's not enough inventory and # apparently that's normal according to @jco and @sle with so_form.order_line.new() as line: line.product_id = cross_shop_product.product_variant_ids line.product_uom_qty = 100.0 sale_order_crossdock = so_form.save() # Confirm sales order sale_order_crossdock.action_confirm() # Run the scheduler self.env['procurement.group'].run_scheduler() # Check a quotation was created for the created supplier and confirm it po = self.env['purchase.order'].search([('partner_id', '=', supplier_crossdock.id), ('state', '=', 'draft')]) self.assertTrue(po, "an RFQ should have been created by the scheduler") po.button_confirm()
def test_create_res_lang(self): lang_form = Form(self.env['res.lang']) lang_form.name = 'a lang name' lang_form.code = 'a lang code' lang_form.save()