board.GetLayerStack() was removed in KiCad 9. Call SetLayerName and SetLayerType directly on the board instead, and grow the copper layer count via SetCopperLayerCount when adding inner layers. Without this, add_layer raises AttributeError on any KiCad 9 installation.