'Basic order test: no routing (thus no workorders), no lot'

def test_basic(self):

    inventory = self.env['stock.inventory'].create({'name': 'Initial    inventory', 'filter': 'partial', 'line_ids': [(0, 0, {'product_id': self.product_1.id, 'product_uom_id': self.product_1.uom_id.id, 'product_qty': 500, 'location_id': self.warehouse_1.lot_stock_id.id}), (0, 0, {'product_id': self.product_2.id, 'product_uom_id': self.product_2.uom_id.id, 'product_qty': 500, 'location_id': self.warehouse_1.lot_stock_id.id})]})
    inventory.action_done()
    test_date_planned = (datetime.now() - timedelta(days=1))
    test_quantity = 2.0
    self.bom_1.routing_id = False
    man_order = self.env['mrp.production'].sudo(self.user_mrp_user).create({'name': 'Stick-0', 'product_id': self.product_4.id, 'product_uom_id': self.product_4.uom_id.id, 'product_qty': test_quantity, 'bom_id': self.bom_1.id, 'date_planned_start': test_date_planned, 'location_src_id': self.location_1.id, 'location_dest_id': self.warehouse_1.wh_output_stock_loc_id.id})
    self.assertEqual(man_order.state, 'confirmed', 'Production    order    should    be    in    confirmed    state.')
    production_move = man_order.move_finished_ids
    self.assertEqual(production_move.date, Dt.to_string(test_date_planned))
    self.assertEqual(production_move.product_id, self.product_4)
    self.assertEqual(production_move.product_uom, man_order.product_uom_id)
    self.assertEqual(production_move.product_qty, man_order.product_qty)
    self.assertEqual(production_move.location_id, self.product_4.property_stock_production)
    self.assertEqual(production_move.location_dest_id, man_order.location_dest_id)
    for move in man_order.move_raw_ids:
        self.assertEqual(move.date, Dt.to_string(test_date_planned))
    first_move = man_order.move_raw_ids.filtered((lambda move: (move.product_id == self.product_2)))
    self.assertEqual(first_move.product_qty, (((test_quantity / self.bom_1.product_qty) * self.product_4.uom_id.factor_inv) * 2))
    first_move = man_order.move_raw_ids.filtered((lambda move: (move.product_id == self.product_1)))
    self.assertEqual(first_move.product_qty, (((test_quantity / self.bom_1.product_qty) * self.product_4.uom_id.factor_inv) * 4))
    qty_wizard = self.env['change.production.qty'].create({'mo_id': man_order.id, 'product_qty': 3.0})
    produce_wizard = self.env['mrp.product.produce'].sudo(self.user_mrp_user).with_context({'active_id': man_order.id, 'active_ids': [man_order.id]}).create({'product_qty': 1.0})
    produce_wizard.do_produce()
    man_order.button_mark_done()
    self.assertEqual(man_order.state, 'done', 'Production    order    should    be    in    done    state.')
